Condividi tramite


Using Image Lists in an Extended Combo Box Control

The main feature of extended combo box controls is the ability to associate images from an image list with individual items in a combo box control. Each item is able to display three different images: one for its selected state, one for its nonselected state, and a third for an overlay image.

The following procedure associates an image list with an extended combo box control:

To associate an image list with an extended combo box control

  1. Construct a new image list (or use an existing image list object), using the CImageList constructor and storing the resultant pointer.

  2. Initialize the new image list object by calling CImageList::Create. The following code is one example of this call.

    m_ComboImageList.Create(16, 16, ILC_COLOR, 2, 2);
    
  3. Add optional images for each possible state: selected or nonselected, and an overlay. The following code adds three predefined images.

    m_ComboImageList.Add(AfxGetApp()->LoadIcon(IDI_ICON1));
    m_ComboImageList.Add(AfxGetApp()->LoadIcon(IDI_ICON2));  
    m_ComboImageList.Add(AfxGetApp()->LoadIcon(IDI_ICON3));
    
  4. Associate the image list with the control with a call to CComboBoxEx::SetImageList.

Once the image list has been associated with the control, you can individually specify the images each item will use for the three possible states. For more information, see Setting the Images for an Individual Item.

See Also

Reference

Using CComboBoxEx

Concepts

Controls (MFC)