Udostępnij za pośrednictwem


CONTAINER Sample: Visual Editing Container Application

The CONTAINER sample is a simple example of a Visual Editing container application.

CONTAINER illustrates the following:

  • Container starter code created by the application wizard.

  • The application-specific classes CContainerItem and CContainerView and the MFC classes COleClientItem and COleDocument.

  • Selection and hit detection of embedded objects.

  • Activation of embedded objects.

  • Tracker rectangles using the CRectTracker class.

For examples of more advanced Visual Editing container features, see the DRAWCLI and OCLIENT sample applications.

Security noteSecurity 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. Microsoft assumes no liability for incidental or consequential damages should the sample code be used for purposes other than as intended.

To get samples and instructions for installing them:

  • On the Visual Studio Help menu, click Samples.

    For more information, see Visual Studio Samples.

  • The most recent version and complete list of samples is available online from the Visual Studio 2008 Samples page.

  • You can also locate samples on your computer's hard disk. By default, samples and a Readme file are copied into a folder under \Program Files\Visual Studio 9.0\Samples\. For Express editions of Visual Studio, all samples are located online.

Building and Running the Sample

To build and run the CONTAINER sample

  1. Open the solution container.sln.

  2. On the Build menu, click Build.

  3. On the Debug menu, click Start Without Debugging.

Keywords

The CONTAINER sample demonstrates the following keywords:

AfxMessageBox; AfxOleInit; AfxThrowMemoryException; CArchive::IsStoring; CCmdTarget::BeginWaitCursor; CCmdTarget::EndWaitCursor; CDC::HIMETRICtoDP; CDialog::DoModal; CDocTemplate::SetContainerInfo; CDocument::OnNewDocument; CFrameWnd::Create; CFrameWnd::DockControlBar; CFrameWnd::EnableDocking; CFrameWnd::LoadFrame; CObject::AssertValid; CObject::Dump; CObject::Serialize; COleClientItem::Close; COleClientItem::CreateFromClipboard; COleClientItem::Deactivate; COleClientItem::Delete; COleClientItem::DoVerb; COleClientItem::Draw; COleClientItem::GetActiveView; COleClientItem::GetDocument; COleClientItem::GetInPlaceWindow; COleClientItem::GetItemState; COleClientItem::IsInPlaceActive; COleClientItem::OnChange; COleClientItem::OnChangeItemPosition; COleClientItem::OnDeactivateUI; COleClientItem::OnGetItemPosition; COleClientItem::SetItemRects; COleClientItem::UpdateLink; COleDocument::EnableCompoundFile; COleDocument::GetNextItem; COleDocument::GetStartPosition; COleInsertDialog::CreateItem; COleInsertDialog::DoModal; COleInsertDialog::GetSelectionType; CRect::PtInRect; CRect::SetRect; CRect::Size; CRectTracker::Draw; CRectTracker::GetTrueRect; CRectTracker::SetCursor; CRectTracker::Track; CView::DoPreparePrinting; CView::GetDocument; CView::IsSelected; CView::OnBeginPrinting; CView::OnDraw; CView::OnEndPrinting; CView::OnInitialUpdate; CView::OnPreparePrinting; CView::OnUpdate; CWinApp::AddDocTemplate; CWinApp::EnableShellOpen; CWinApp::InitInstance; CWinApp::LoadStdProfileSettings; CWinApp::RegisterShellFileTypes; CWnd::DoDataExchange; CWnd::Invalidate; CWnd::InvalidateRect; CWnd::OnCreate; CWnd::OnLButtonDblClk; CWnd::OnLButtonDown; CWnd::OnSetCursor; CWnd::OnSetFocus; CWnd::OnSize; CWnd::PreCreateWindow; CWnd::SetFocus; CWnd::ShowWindow; CWnd::UpdateWindow; DragAcceptFiles; GetKeyState

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

Other Resources

MFC Samples