Share via


ActiveX Control Containers: Connecting an ActiveX Control to a Member Variable

OverviewHow Do ISample

The easiest way to access an ActiveX control from within its control container application is to associate the ActiveX control with a member variable of the dialog class that will contain the control.

Note   This is not the only way to access an embedded control from within a container class, but for the purposes of this article it is sufficient.

Adding a member variable to the dialog class

  1. Load your ActiveX container project.

  2. On the View menu, click ClassWizard.

  3. Choose the Member Variables tab.

  4. In the Class Name list box, select the main dialog class. For example, CContainerDlg.

  5. In the Control IDs list box, select the control ID of the embedded ActiveX control. For example, IDC_CIRC2CTRL1.

  6. Click Add Variable.

    The Add Member Variable dialog box appears.

  7. In the Member Variable Name box enter a name.

    For example, m_circ2ctl.

  8. In the Category box, click Control.

    The Variable Type edit box automatically contains the name of the control wrapper class.

    Note   Additional entries in the Category drop-down list box are for exposed properties of the ActiveX control.

  9. Click OK to close the Add Member Variables dialog box.

  10. Click OK to accept your choices and exit ClassWizard.