This documentation is archived and is not being maintained.

BINDSCRB Sample: Illustrates an MFC Binder-Compatible Server

Visual Studio .NET 2003

The BINDSCRB sample illustrates the use of Active interfaces for components used to build Active documents. An application that is an Active document server can be contained in any Active document object container. The sample is so named because the Microsoft Office Binder, included in Microsoft Office, was the first tool to support containment of these objects. The Binder acts as a client, while the documents are served by Active document servers.

BINDSCRB behaves like the SCRIBBLE sample but shares the user interface of its container if its container supports Active documents. If the container does not support Active documents, BINDSCRB behaves like a normal Active component. Active document containers include certain MFC applications (see Creating an Active Document Container Application), Microsoft Office Binder, Microsoft Word, and Microsoft Internet Explorer 3.0 and later. The Active interfaces provided by an Active document container differ slightly from normal Active interfaces so that the Binder can provide a specialized user environment.

Building and Running the Sample

To build and run the BINDSCRB sample

  1. Open the solution scribble.sln.
  2. On the Build menu, click Build.
  3. Run BINDSCRB once as a stand-alone application so it can register itself with the system.

When you run BINDSCRB, note that it looks much like the SCRIBBLE sample.

After you close BINDSCRB, you can start the Office Binder, Microsoft Internet Explorer 3.0 and later, or any other Active document container application. Use the command appropriate for that application to insert the BINDSCRB object into the container. If you use the Office Binder, for example, click Add on the Section menu to reach the Add Section dialog box. The Add Section dialog box has an entry in the As a Blank Section list box that corresponds to the BINDSCRB sample. Select this entry and click OK in the dialog box to add a new BINDSCRB document to the binder.

If you are using Microsoft Word, you can insert the BINDSCRB object directly onto the document.

To run the BINDSCRB sample in Microsoft Word

  1. On the Insert menu, click Object to display the Create New tab of the object document.
  2. Select DocObject Scrib Document from the list and click OK to add a new BINDSCRB object to the Word document.

    Note that the menu has changed to display the menu of the BINDSCRB document. You can draw on it and set pen widths directly, as you would if you were running BindScrb.exe on its own.

Because BINDSCRB implements all the necessary binder interfaces for persistence, you can load and save the content of the binder in a Binder file, including any changes you make to the sample. Similarly, you can open a Binder file and expect to see a BINDSCRB document with your changes.

How BINDSCRB Works

BINDSCRB works by adding implementations of the binder-specific Active interfaces to the interfaces that MFC classes enabled for Active documents, like COleServerDocument, already support. It does this by registering itself with MFC as an Active document server application. MFC contains code to support these new interfaces. For more information, see the following classes and articles:

Keywords

This sample demonstrates the following keywords:

AfxMessageBox; AfxOleInit; CArchive::IsStoring; CCmdUI::Enable; CCmdUI::SetCheck; CControlBar::EnableDocking; CControlBar::GetBarStyle; CControlBar::SetBarStyle; CDC::DPtoLP; CDC::GetDeviceCaps; CDC::GetTextMetrics; CDC::LPtoDP; CDC::LPtoHIMETRIC; CDC::LineTo; CDC::MoveTo; CDC::SelectObject; CDC::SetMapMode; CDC::SetTextAlign; CDC::SetViewportExt; CDC::SetWindowExt; CDC::SetWindowOrg; CDC::TextOut; CDialog::DoModal; CDocTemplate::SetServerInfo; CDocument::DeleteContents; CDocument::GetFirstViewPosition; CDocument::GetNextView; CDocument::OnNewDocument; CDocument::OnOpenDocument; CDocument::SetModifiedFlag; CDocument::UpdateAllViews; CFont::CreateFontIndirect; CFrameWnd::Create; CFrameWnd::DockControlBar; CFrameWnd::EnableDocking; CFrameWnd::LoadFrame; CFrameWnd::OnCreateClient; CObList::GetHeadPosition; CObList::GetNext; CObject::AssertValid; CObject::Dump; CObject::IsKindOf; CObject::Serialize; COleDocIPFrameWnd; COleDocument::EnableCompoundFile; COleIPFrameWnd::OnCreateControlBars; COleServerDoc::GetEmbeddedItem; COleServerDoc::GetZoomFactor; COleServerDoc::NotifyChanged; COleServerDoc::OnGetEmbeddedItem; COleServerDoc::OnSetItemRects; COleServerItem::CopyToClipboard; COleServerItem::GetDocument; COleServerItem::IsLinkedItem; COleServerItem::OnDraw; COleServerItem::OnGetExtent; COleTemplateServer::ConnectTemplate; COleTemplateServer::UpdateRegistry; CPen::CreatePen; CRect::InflateRect; CRect::IntersectRect; CRect::SetRectEmpty; CScrollView::SetScrollSizes; CSplitterWnd::Create; CStatusBar::Create; CStatusBar::SetIndicators; CToolBar::Create; CView::DoPreparePrinting; CView::GetDocument; CView::OnBeginPrinting; CView::OnDraw; CView::OnEndPrinting; CView::OnInitialUpdate; CView::OnPrepareDC; CView::OnPreparePrinting; CView::OnPrint; CView::OnUpdate; CWinApp::AddDocTemplate; CWinApp::InitInstance; CWinApp::LoadStdProfileSettings; CWnd::DoDataExchange; CWnd::GetCapture; CWnd::Invalidate; CWnd::InvalidateRect; CWnd::OnCreate; CWnd::OnLButtonDown; CWnd::OnLButtonUp; CWnd::OnMouseMove; CWnd::OnSize; CWnd::PreCreateWindow; CWnd::SetCapture; CWnd::SetOwner; CWnd::ShowWindow; CWnd::UpdateWindow; CreatePen; DeleteObject; DragAcceptFiles; GetClipBox; LPtoDP; RGB; ReleaseCapture; SetRectEmpty; max; memset; min

Note   Some samples, such as this one, have not been modified to reflect the changes in the Visual C++ wizards, libraries, and compiler, but still demonstrate how to complete your desired task.

See Also

MFC Samples

Show: