ACTIVEDOC Sample: Implements an Active Document Server

The ACTIVEDOC sample demonstrates how to implement an Active Document Server. The sample demonstrates the following:

Security Note

This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices.

Building and Running the Sample

To build the sample

  1. Open the solution ActiveDoc.sln.

  2. From the Build menu, click Build Solution.

To run the sample using Internet Explorer

  1. Open ActiveDoc.htm or the ActiveDoc.AAA generated file in Internet Explorer (to open ActiveDoc.AAA, click the Open button when prompted to open this file).

  2. Use the Format menu that has been merged into Internet Explorer's menu bar, or just click the toolbar colors to change the color of the typed text.

To run the sample using Microsoft Office Binder

  1. Run Microsoft Office Binder and from the Section menu click Add.

  2. Select the icon labeled "ActiveDoc Class" and click OK.

    You should see the object embedded in Office Binder. Notice that the menus have been merged and the ActiveDoc's toolbar is shown. You can enter text and use the menu and toolbar buttons to change the color of the text that is typed.

Sample Files

The sample includes the following main files:

  • ActiveCtl.h

  • ActiveCtl.cpp — implements CActiveDoc, which represents the overall ActiveDoc object.

  • OleDocument.h — contains the implementation of the IOleDocument and IOleDocumentView interfaces.

  • Toolbar.h — contains CToolbar, which helps with the implementation of the toolbar.

Keywords

This sample uses the following keywords:

ActiveXDocActivate; ALT_MSG_MAP; ATLASSERT; ATLTRACE; BEGIN_COM_MAP; BEGIN_MSG_MAP; BEGIN_OBJECT_MAP; BEGIN_PROPERTY_MAP; BEGIN_TOOLBAR_MAP; CAboutDlg::DoModal; CanInPlaceActivate; CComCoClass; CComControl; CComModule::GetClassObject; CComModule::GetLockCount; CComModule::Init; CComModule::RegisterServer; CComModule::Term; CComModule::UnregisterServer; CComObjectRoot; CComObjectRootEx::InternalQueryInterface; CComPtr; CHARFORMAT; CMenu; COM_INTERFACE_ENTRY; COM_INTERFACE_ENTRY_IMPL; COMMAND_ID_HANDLER; COMMAND_RANGE_HANDLER; CreateMenu; CreateRTFWindow; CreateToolbar; CreateWindowEx; CToolbar; CWindow::DestroyWindow; CWindow::ModifyStyle; CWindow::SetFocus; CWindow::SetParent; CWindow::SetWindowPos; DECLARE_REGISTRY_RESOURCEID; DestroyMenu; DestroyToolbar; DisableThreadLibraryCalls; DllMain; DoesVerbUIActivate; EDITSTREAM::dwCookie; EDITSTREAM::dwError; EDITSTREAM::pfnCallback; Ellipse; END_COM_MAP; END_MSG_MAP; END_OBJECT_MAP; END_PROPERTY_MAP; END_TOOLBAR_MAP; EndDialog; ExtTextOut; FreeLibrary; GetMenuItemCount; GetMenuItemID; GetMenuState; GetMenuString; GetResourceInstance; GetStockObject; GetSubMenu; GetTextMetrics; GetWindow; GetWindowContext; GetWindowRect; HDC; hdcDraw;; IDataObjectImpl; IDispatchImpl; InitCommonControls; InlineIsEqualGUID; InPlaceDeactivate; InPlaceMenuCreate; InPlaceMenuDestroy; InsertMenu; InterfaceSupportsErrorInfo; InternalQueryInterface; IOleControlImpl; IOleDocument::GetDocMiscStatus; IOleDocumentImpl; IOleDocumentView::ApplyViewState; IOleDocumentView::SetInPlaceSite; IOleDocumentViewImpl; IOleInPlaceActiveObjectImpl; IOleInPlaceFrame*   pFrame;; IOleInPlaceFrame::InsertMenus; IOleInPlaceFrame::Release; IOleInPlaceFrame::SetMenu; IOleInPlaceObjectWindowlessImpl; IOLEInPlaceSite::GetWindowContext; IOleObjectImpl; IPersistStorageImpl; IPersistStreamInitImpl; IProvideClassInfo2Impl; IQuickActivateImpl; ISupportErrorImpl; IViewObjectExImpl; LoadLibrary; LoadMenu; LoadString; MAKEINTRESOURCE; MergeMenus; MESSAGE_HANDLER; NOTIFY_CODE_HANDLER; OBJECT_ENTRY; OleCreateMenuDescriptor; OLEINPLACEFRAMEINFO; OnInPlaceActivate; OnUIActivate; prcBounds; RECT rcPos, rcClip;; RemoveMenu; SelectObject; SendMessage; SetActiveObject; SetBkMode; SetBorderSpace; SetControlFocus; SetFocus; SetInPlaceSite; SetMenu; SetObjectRects; SetTextColor; ShowObject; ShowWindow; UIActivate; UIDeactivate; UnmergeMenus; ZeroMemory