COLLECT: Illustrates MFC Collection Classes

Click to open or copy the COLLECT project files.

COLLECT illustrates a wide variety of collection classes offered by the Microsoft Foundation Class Library (MFC).

The MFC collection classes can be classified according to shape and design. MFC offers classes for three types of collection shapes:

and three types of designs:

The following table identifies all the MFC collection classes sorted according to shape and design. The COLLECT sample illustrates nine of these collections, one from each cell in the table. Each represents a distinct combination of shape and design. Also, because usage of the CTypedPtrArray and CTypedPtrList template-based collections differs according to whether they are used to hold pointers to CObjects or to non-CObjects, the COLLECT sample illustrates both cases. The nine collections illustrated by COLLECT are indicated with an asterisk.

Collection shapes Non-template based Template-based simple elements Template-based typeSafe pointers
List CStringList* CList* CTypedPtrList
CObList (of pointers)*
CPtrList CTypedPtrList
(of CObjects)
Array CByteArray CArray* CTypedPtrArray
CUIntArray (of pointers)
CWordArray*
CDWordArray CTypedPtrArray
CStringArray (of CObjects)*
CPtrArray
CObArray
Map CMapWordToPtr CMap* CTypedPtrMap*
CMapWordToOb
CMapStringToString*
CMapStringToPtr
CMapStringToOb
CMapPtrToWord
CMapPtrToPtr

Additional COLLECT Features

In addition to illustrating the MFC collection classes, COLLECT also illustrates:

The Example menu lists nine collection class illustrations organized according to the above table. Each example presents a form view that exercises many of the common collection operations:

You can save changes to all the examples with File Save and read them back with File Open.

This sample demonstrates the following keywords:

AfxMessageBox; CCmdUI::SetCheck; CControlBar::EnableDocking; CDialog::DoModal; CDocument::DeleteContents; CDocument::OnNewDocument; CFrameWnd::DockControlBar; CFrameWnd::EnableDocking; CFrameWnd::GetActiveDocument; CFrameWnd::GetActiveView; CFrameWnd::RecalcLayout; CFrameWnd::SetActiveView; CListBox::AddString; CListBox::DeleteString; CListBox::FindString; CListBox::GetCurSel; CListBox::GetItemData; CListBox::GetItemDataPtr; CListBox::GetText; CListBox::InsertString; CListBox::ResetContent; CListBox::SetItemData; CListBox::SetItemDataPtr; CObject::AssertValid; CObject::Dump; CObject::Serialize; CStatusBar::Create; CStatusBar::SetIndicators; CString::Empty; CString::Format; CString::LoadString; CToolBar::Create; CToolBar::LoadBitmap; CToolBar::SetButtons; CView::DoPreparePrinting; CView::GetDocument; CView::OnBeginPrinting; CView::OnDraw; CView::OnEndPrinting; CView::OnInitialUpdate; CView::OnPreparePrinting; CView::OnUpdate; CWinApp::AddDocTemplate; CWinApp::Enable3dControls; CWinApp::InitInstance; CWinApp::LoadStdProfileSettings; CWinApp::OnFileNew; CWnd::DestroyWindow; CWnd::DoDataExchange; CWnd::OnCreate; CWnd::ShowWindow; CWnd::UpdateData; LoadString; SetWindowLong