Creating an Active Document Container Application
The simplest and most recommended way to create an active document container application is to create an MFC EXE container application using the MFC Application Wizard, then modify the application to support active document containment.
To create an active document container application
From the File menu, click Projectfrom the New submenu.
From the left pane, click Visual C++ project type.
Select MFC Application from the right pane.
Name the project MyProj, click OK.
Select the Compound Document Support page.
Select the Container or Container/Full-server option.
Select the Active document container check box.
When the MFC Application Wizard finishes generating the application, open the following files using Solution Explorer:
In MyProjview.cpp, make the following changes:
In CMyProjView::OnPreparePrinting, replace the function contents with the following code:
OnPreparePrinting provides printing support. This code replaces DoPreparePrinting, which is the default print preparation.
Active document containment provides an improved printing scheme:
You can first call the active document through its IPrintinterface and tell it to print itself. This is different from previous OLE containment, in which the container had to render an image of the contained item onto the printer CDCobject.
If that fails, tell the contained item to print itself through its IOleCommandTargetinterface
If that fails, make your own rendering of the item.
The static member functions COleDocObjectItem::OnPrint and COleDocObjectItem::OnPreparePrinting, as implemented in the previous code, handle this improved printing scheme.
Add any implementation of your own and build the application.