Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

CONTAINER Sample: Visual Editing Container Application 

Download sample

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.

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.


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


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

Community Additions

© 2015 Microsoft