ActiveX Control Containers: Manually Enabling ActiveX Control Containment

OverviewHow Do ISample

If you did not enable ActiveX control support when you used AppWizard to generate your application, you will have to add this support manually. This article describes the process for manually adding ActiveX control containment to an existing OLE container application. If you know in advance that you want ActiveX control support in your OLE container, see the article . In addition, you can use the Gallery’s ActiveX control Containment component to automatically add control containment to your application.

Note   This article uses a dialog-based ActiveX control container project named Container and an embedded control named Circ2 as examples in the procedures and code.

To support ActiveX controls, you must add one line of code to two of your project’s files.

  • Modify your main dialog’s InitInstance function (found in CONTAINER.CPP) by making a call to , as in the following example:

    // CContainerApp initialization
    
    BOOL CContainerApp::InitInstance()
    {
    AfxEnableControlContainer();
    ...
    }
    
  • Add the following to your project’s STDAFX.H header file:

    #include <Afxdisp.h>
    

After you have completed these steps, rebuild your project by clicking Build on the Build menu.