Shortcut for Defining Message Handlers for Dialog Buttons

OverviewHow Do I

Note   This article applies only to dialog button controls within an MFC project. ATL projects should use the New Windows Messages and Event Handlers dialog box.

To define a message handler for a dialog button, you can use the following convenient shortcut to bypass some intermediate steps.

To define a message handler for a dialog box button

  1. In the dialog editor, select a button.

  2. While holding down the CTRL key, double-click the button.

    ClassWizard automatically creates a message handler in the class associated with the dialog box. The message handler is named according to the control ID of the dialog box button. Finally, the insertion point moves to the newly created function in your source code.

    -or-

  3. In the Dialog editor, double-click on the button.

  4. If a class is not already associated with the dialog, ClassWizard appears, along with an Adding a Class dialog box, which prompts you to provide a class for the new resource. You can either create a new class or select an existing class.

    If a class is already associated with the dialog box, the Add Member Function dialog box opens if no message handler for the control is implemented yet. If a message handler for the control is already implemented, you navigate directly to that handler's definition.