MFC: VS 2010 class wizard doesn't show the class names for the Dialog boxes
Iam learning MFC currently. On VS 2010 dialog editor, i created a listbox and few buttons on a dialog. Then i added a listbox member variable using the class wizard.
Now when i try the same thing again for a button, i find the class wizard is empty. 开发者_运维百科It just shows the project name. It doesn't show anything else.
Can someone help?
I enclosed the dialog class using a namespace. That caused the problem.
Classes inside namespaces are not supported by Class Wizard it seems.
There is a workaround but it involves preprocessor macros.
- Replace the declarations that start and end your namespace with macros that are defined to do the same thing.
- Add a file called cpp.hint in the same directory as your project file
- Edit the cpp.hint and add do-nothing versions of your namespace macros.
cpp.hint is only used by class wizard not the compiler. The above fix means class wizard doesn't see your classes within the namespace but the compiler does. So class wizard works and your classes are still within the same namespaces as before.
See https://connect.microsoft.com/VisualStudio/feedback/details/543019/class-wizard-and-class-view-does-not-detect-namespaces-changes-in-configurations.
I have not tried it myself yet, but if you are using VS2010, perhaps this extension can be of use (claiming to support namespaces):
https://visualstudiogallery.msdn.microsoft.com/e35dfd63-8023-450d-be21-d58be27def61
精彩评论