Share via


Declaring a Variable Based on Your New Control Class

Once you have created an MFC control class, you can declare a variable based on it. To provide a context for the new variable, you must open the dialog editor and edit the dialog box in which you want to use your reusable control. Also, the dialog box must already have a class associated with it. For information on using the dialog editor, see Dialog Editor.

To declare a variable based on your reusable class

  1. While editing the dialog box, drag a control of the same type as the base class of your new control from the Controls toolbar onto the dialog box.

  2. Place the mouse pointer over the dropped control.

  3. While pressing the CTRL key, double-click the control.

    The Add Member Variable dialog box appears.

  4. In the Access box, select the correct access for your control.

  5. Click the Control variable check box.

  6. In the Variable name box, type a name.

  7. Under Category, click Control.

  8. In the Control ID list, pick the control that you added. The Variable type list should display the correct variable type, and the Control type box should display the correct control type.

  9. In the Comment box, add any comment you want to appear in your code.

  10. Click OK.

See Also

Tasks

Mapping Messages to Functions

Adding a Member Function

Adding a Member Variable

Overriding a Virtual Function

Reference

Navigating the Class Structure

Concepts

Adding Functionality with Code Wizards

Adding a Class

Adding an MFC Message Handler