Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
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: Manually Enabling ActiveX Control Containment 

If you did not enable ActiveX control support when you used the MFC Application Wizard 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 Creating an MFC ActiveX Control Container.

NoteNote

This article uses a dialog-based ActiveX control container project named Container and an embedded control named Circ 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 the MFC Application Wizard making a call to AfxEnableControlContainer, 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.

Community Additions

ADD
Show:
© 2015 Microsoft