Header items have the ability to display an image within a header item. This image, stored in an associated image list, is 16 x 16 pixels and has the same characteristics as the icon images used in a list view control. In order to implement this behavior successfully, you must first create and initialize the image list, associate the list with the header control, and then modify the attributes of the header item that will display the image.
The following procedure illustrates the details, using a pointer to a header control (m_pHdrCtrl
) and a pointer to an image list (m_pHdrImages
).
To display an image in a header item
m_pHdrImages->Create(16, 16, ILC_MASK, 2, 2);
m_pHdrImages->Add(pApp->LoadIcon(IDI_ICONHDR1));
m_pHdrImages->Add(pApp->LoadIcon(IDI_ICONHDR2));
m_phdrImages
, to the first header item, m_pHdrCtrl
.
HDITEM curItem;
m_pHdrCtrl->SetImageList(m_pHdrImages);
m_pHdrCtrl->GetItem(0, &curItem);
curItem.mask= HDI_IMAGE | HDI_FORMAT;
curItem.iImage= 0;
curItem.fmt= HDF_LEFT | HDF_IMAGE | HDF_STRING;
m_pHdrCtrl->SetItem(0, &curItem);
For detailed information on the parameter values used, consult the pertinent CHeaderCtrl.
Note It is possible to have multiple controls using the same image list. For instance, in a standard list view control, there could be an image list (of 16 x 16 pixel images) used by both the small icon view of a list view control and the header items of the list view control.