|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.|
ActiveX Control Containers: Connecting an ActiveX Control to a Member Variable
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.
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
From Class View, right-click the main dialog class to open the shortcut menu. For example, CContainerDlg.
From the shortcut menu, click Add and then Add Variable.
In the Add Member Variable Wizard, click Control variable.
In the Control ID list box, select the control ID of the embedded ActiveX control. For example, IDC_CIRCCTRL1.
In the Variable Name box, enter a name.
For example, m_circctl.
Click Finish to accept your choices and exit the Add Member Variable Wizard.