Copyright: OLE Control Containment Help


OLE Control Containment: Overview

The OLE control containment component adds OLE control support to your application. Once you have inserted this component, your application can support embedded OLE controls in any CCmdTarget-derived class, such as a dialog or view.

OLE Control Containment: Specifics

OLE Control Containment: Results

Note   This component will not work on Macintosh platforms.


OLE Control Containment: Specifics

To support OLE control containment, a project must include afxdisp.h and a call to AfxEnableControlContainer in the InitInstance function. This function is a member of the project's CWinApp-derived class.

For more information on OLE control containment, see the article "OLE Control Containers" in Programming with MFC: Encyclopedia.


OLE Control Containment: Results

When the component is inserted, two lines are added in two files of the project.

•	The first line is an include file, afxdisp.h, that is needed by any embedded OLE control. It is placed at the end of your stdafx.h file. Afxdisp.h is one of many include file provided by Microsoft and should not be modified in any way.

•	The second line is a call to the function AfxEnableControlContainer, a global function provided by Microsoft. It is placed at the beginning of your application's InitInstance function. This function can be found in PROJECT.CPP, where PROJECT is the name of the project. This function enables support for OLE control containment.

Both lines of code are suffixed by the comment:

//added by OCC component

Once you have inserted this component, see the article "OLE Control Containers: Inserting a Control into a Control Container Application" in Programming with MFC: Encyclopedia for information on how to use OLE controls in your application.