ClassWizard: Special-Format Comment Sections

HomeOverviewHow Do ITutorial

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:

Message-Map Comments

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.

Virtual Function Comments

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.

Data Map Comments

For dialog boxes, form views, and record views, ClassWizard creates and edits three other sections that are marked with special format comments:

Field Map Comments

For record field exchange, ClassWizard creates and edits three other sections that are marked with special format comments:

Active Dispatch Map Comments

For Active method dispatch, ClassWizard creates and edits four other sections that are marked with special format comments:

For more information see Working with Dialog Box Data.