How to Manage Commands and Messages with ClassWizard
ClassWizard is a tool is designed specifically to connect Windows messages and user-interface objects such as menus to their handlers.
The typical development scenarios are as follows:
You determine that one of your classes must handle a certain Windows message, so you run ClassWizard and make the connection.
You create a menu or accelerator resource, then invoke ClassWizard to connect the command associated with that object to a handler.
As you work with the framework, you’ll find that ClassWizard greatly simplifies your message-management tasks.
ClassWizard writes the following information to your source files:
The appropriate message-map entry for the connection
A declaration of the handler as a member function of the class
An empty function template for you to fill in with the handler’s code
For detailed information about using ClassWizard to connect messages to handlers, see Working with Classes Topics. For examples, see the tutorials and .
Important Use ClassWizard to create and edit all message-map entries. If you add them manually, you may not be able to edit them with ClassWizard later. If you add them outside the bracketing comments //{{AFX_MSG_MAP(classname)
and //}}AFX_MSG_MAP
, ClassWizard cannot edit them at all. Note that by the same token ClassWizard will not touch any entries you add outside the comments, so feel free to add messages outside the comments if you do not want them to be modified. Some messages, such as message-map ranges, must be added outside the comments.