Home | Overview | How Do I | Tutorial
This article explains where and how ClassWizard edits your source files.
When you add a new class using ClassWizard, special-format comments are placed in your code to mark the sections of the header and implementation files that ClassWizard edits. ClassWizard never modifies code that is outside these commented sections.
ClassWizard creates the following types of comments in your code:
For most classes, there are two related sections of code that ClassWizard edits: the member-function definitions in the class header file and the message-map entries in the class implementation file.
The ClassWizard comments in the header file look like this:
//{{AFX_MSG(<classname>)
afx_msg void OnAppAbout();
//}}AFX_MSG
The ClassWizard section in the implementation file is set off with comments that look like this:
//{{AFX_MSG_MAP(<classname>)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
//}}AFX_MSG_MAP
The notes in the ClassWizard section act as placeholders. ClassWizard removes the note from any ClassWizard section in which it writes code.
As with message handlers, ClassWizard writes code to two locations when you use it to override a virtual function in one of your classes.
The ClassWizard comments in the header file look like the following example for virtual function overrides:
//{{AFX_VIRTUAL(<classname>)
virtual BOOL InitInstance();
//}}AFX_VIRTUAL
The ClassWizard section in the implementation file has no special comments. Virtual function definitions in the .cpp file look like other function definitions.
For dialog boxes, form views, and record views, ClassWizard creates and edits three other sections that are marked with special format comments:
//{{AFX_DATA
..
//}}AFX_DATA
//{{AFX_DATA_INIT
..
//}}AFX_DATA_INIT
//{{AFX_DATA_MAP
..
//}}AFX_DATA_MAP
For record field exchange, ClassWizard creates and edits three other sections that are marked with special format comments:
//{{AFX_FIELD
..
//}}AFX_FIELD
//{{AFX_FIELD_MAP
..
//}}AFX_FIELD_MAP
//{{AFX_FIELD_INIT
..
//}}AFX_FIELD_INIT
For Active method dispatch, ClassWizard creates and edits four other sections that are marked with special format comments:
//{{AFX_EVENT
..
//}}AFX_EVENT
//{{AFX_EVENT_MAP
..
//}}AFX_EVENT_MAP
//{{AFX_DISP
..
//}}AFX_DISP
//{{AFX_DISP_MAP
..
//}}AFX_DISP_MAP
For more information see Working with Dialog Box Data.