Question

Is there a way in VS2010 to import a class from a .h and .cpp file into ClassWizard such that I can use ClassWizard to manipulate it (e.g. add variables etc...) Quite a number of the files that I brought into the project when I moved over from VS2008 do not seem to be available to ClassWizard. Back in VS6, I could do this by manually editing the CLW file, but this is no longer available. See related question

I'm guessing the file that stores this information is MyProjectName.sdf, which is listed as a SQL Server Compact Edition Database File by explorer, but I'm not sure if there are any tools available that would let me edit it.

Was it helpful?

Solution

Figured a workaround. My hunch was that VS2010 was reading the //{{AFX_DATA(CMyClass) comments when existing files are added into a project, so I did the following;

  • Edit the files to include a set of AFX... comments copied from another class
  • Replace the class name with the correct class
  • Remove the .h and .cpp files from the project
  • Add the .h files and .cpp files back to the project
  • The class is now available to ClassWizard.

A bit too much work to be of much benefit on anything other than regularly used classes, might just put together a routine to do this en-masse, i.e. search for project files with classes based on known MFC classes, search for absence of AFX comments and add them if not present, say ten hail marys and fire up ClassWizard.

Also posted on MSDN here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top