Share via


Connecting a Class to a Dialog Box

Once you’ve specified the appearance of your dialog box, you can specify its run-time behavior. This requires deriving a class from CDialog that implements your dialog box, and connecting that class to the dialog resource you created in the previous topic.

To connect a class to a dialog box:

  1. Declare a class to represent the dialog box.

  2. Declare handler functions for the messages you want to handle.

  3. Map the dialog box controls to member variables of the dialog class and define what (if any) validation rules should be applied to each.

You could do all of this manually, but WizardBar provides a graphical user interface to do it quickly and easily. ClassWizard generates a header (.h) and an implementation (.cpp) file for your dialog class, complete with function prototypes, skeletal function definitions, a message map, and a data map.

The following topics show how these steps are accomplished for Scribble’s Pen Widths dialog box.