MFCBIND: Active Document Container

Click to open or copy the MFCBIND project files.

The MFC Binder sample shows how to create an Active document (formerly known as a DocObject) container using the Active document container support classes in MFC. The MFC Binder sample is an SDI application that uses the COleDocObjectItem class to represent an embedded Active document in an MFC document. MFCBIND works much like the Office Binder application, which ships with Microsoft Office.

To use MFC Binder, start the application and click the Add menu item from the Section menu to add as many sections as you want to the binder. Examples of sections are Word and Excel documents. When a section is added to the binder, you can edit it directly from within the MFC Binder application as though you were working in the section's native application. When you finish editing the sections in the binder, click the Save command from the File menu to save the binder. The Save command saves the sections in the binder to a single file. When you re-open the binder later, the sections will be available in their previously saved state.

In MFC, Active documents are handled much the same way regular in-place editable embeddings are handled. The COleDocument-derived class still maintains a list of the currently embedded items. The COleClientItem object, which is replaced by the COleClientItem-derived COleDocObjectItem class, represents the embedded item in the COleDocument. It is these COleDocObjectItem-derived items that are maintained in a list by the COleDocument-derived class. Active documents, however, take up the entire client area of the view when they are in-place active. An Active document container also has full control of the Help menu, unlike the older in-place embeddings. The Help menu contains menu items for both the Active document container and server. Because the Active document container owns the Help menu, it is responsible for forwarding messages for the server's part of the Help menu to the server. The help menu merging and message forwarding functionality is completely handled by the MFC framework.

This sample demonstrates the following keywords:

COleClientItem::FinishCreate, COleClientItem::GetIconFromRegistry, IOleObject::GetUserClassID, COleClientItem::OnChange, COleClientItem::OnChangeItemPosition, COleClientItem::OnGetItemPosition, COleClientItem::OnActivate, COleDocument::GetInPlaceActiveItem, COleClientItem::Deactivate, COleClientItem::CreateNewItem, COleClientItem::DoVerb, COleDocObjectItem::COleDocObjectItem, COleClientItem::CreateFromFile, COleClientItem::Activate, COleDocObjectItem::OnPreparePrintin, COleDocObjectItem::OnPrint, SystemParametersInfo, MeasureItem, DrawItem, GetSystemMetrics, SelectObject