Click to open or copy the LISTHDR project files.
LISTHDR 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 of the different available styles. Taken from the old CMNCTRLS sample, the LISTHDR sample has been updated to take advantage of several features implemented in Internet Explorer 4.0.
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 and/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.
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