Export (0) Print
Expand All
Expand Minimize

LISTHDR Sample: Demonstrates the List View and Header Common Controls

Visual Studio .NET 2003

The LISTHDR sample demonstrates how to use the following common control MFC classes: CListCtrl and CHeaderCtrl. It shows how the controls are created and how to change the controls using many different available styles. Taken from the CMNCTRLS sample, the LISTHDR sample has been updated to take advantage of several features implemented in Internet Explorer.

CMNCTRL1 and CMNCTRL2 demonstrate many of the other MFC common controls.

Building and Running the Sample

To build and run the LISTHDR sample

  1. Open the solution listhdr.sln.
  2. On the Build menu, click Build.
  3. On the Debug menu, click Start Without Debugging.

When you run LISTHDR, select the styles and views from the check boxes, radio buttons, and combo boxes available. You will see how each one of the options changes the behavior or appearance of the control being displayed. Some options include dynamically switching between different views, displaying the list view items in four separate working areas, and modifying various other styles. In addition to manipulating the list view control, you can change the appearance of the embedded header control. Some examples include the reordering the header items by dragging and dropping and displaying images in each header item from a separate image list.

There are dependencies between attributes (such as Report view and LVS_NOSORTHEADER). This causes some controls to be disabled or enabled, depending on the current state of the list view control.

Keywords

This sample demonstrates the following keywords:

SetWindowLong, CHeaderCtrl::GetItem, CImageList::Create, CImageList::Add, CListCtrl::SetExtendedStyle, CListCtrl::InsertColumn, CListCtrl::InsertItem, CListCtrl::SetItem, CListCtrl::GetHeaderCtrl, CListCtrl::SetWorkAreas, CListCtrl::ApproximateViewRect, CListCtrl::SetItemPosition, CListCtrl::CreateDragImage, CListCtrl::BeginDrag, CListCtrl::DragEnter, CListCtrl::DragMove, CWnd::ModifyStyleEx, CWnd::ModifyStyle, CWnd::GetDlgItem

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:
© 2014 Microsoft