ActiveX Control Containers: Using Controls in a Non-Dialog Container
In some applications, such as an SDI or MDI application, you will want to embed a control in a window of the application. The Create member function of the wrapper class, inserted by Visual C++, can create an instance of the control dynamically, without the need for a dialog box.
The Create member function has the following parameters:
One example of using this function to dynamically create an ActiveX control would be in a form view of an SDI application. You could then create an instance of the control in the WM_CREATE handler of the application.
For this example, CMyView is the main view class, CCirc is the wrapper class, and CIRC.H is the header (.H) file of the wrapper class.
Implementing this feature is a four-step process.
To dynamically create an ActiveX control in a non-dialog window
Insert CIRC.H in CMYVIEW.H, just before the CMyView class definition:
Add a member variable (of type CCirc) to the protected section of the CMyView class definition located in CMYVIEW.H:
Add a WM_CREATE message handler to class CMyView.
In the handler function, CMyView::OnCreate, make a call to the control's Create function using the this pointer as the parent window:
Rebuild the project. A Circ control will be created dynamically whenever the application's view is created.