Delen via


CComboBoxEx Class

Extends the combo box control by providing support for image lists.

class CComboBoxEx : public CComboBox

Members

Public Constructors

Name

Description

CComboBoxEx::CComboBoxEx

Constructs a CComboBoxEx object.

Public Methods

Name

Description

CComboBoxEx::Create

Creates the combo box and attaches it to the CComboBoxEx object.

CComboBoxEx::CreateEx

Creates a combo box with the specified Windows extended styles and attaches it to a ComboBoxEx object.

CComboBoxEx::DeleteItem

Removes an item from a ComboBoxEx control.

CComboBoxEx::GetComboBoxCtrl

Retrieves a pointer to the child combo box control.

CComboBoxEx::GetEditCtrl

Retrieves the handle to the edit control portion of a ComboBoxEx control.

CComboBoxEx::GetExtendedStyle

Retrieves the extended styles that are in use for a ComboBoxEx control.

CComboBoxEx::GetImageList

Retrieves a pointer to the image list assigned to a ComboBoxEx control.

CComboBoxEx::GetItem

Retrieves item information for a given ComboBoxEx item.

CComboBoxEx::HasEditChanged

Determines if the user has changed the contents of the ComboBoxEx edit control by typing.

CComboBoxEx::InsertItem

Inserts a new item in a ComboBoxEx control.

CComboBoxEx::SetExtendedStyle

Sets extended styles within a ComboBoxEx control.

CComboBoxEx::SetImageList

Sets an image list for a ComboBoxEx control.

CComboBoxEx::SetItem

Sets the attributes for an item in a ComboBoxEx control.

CComboBoxEx::SetWindowTheme

Sets the visual style of the extended combo box control.

Remarks

By using CComboBoxEx to create combo box controls, you no longer need to implement your own image drawing code. Instead, use CComboBoxEx to access images from an image list.

Image List Support

In a standard combo box, the owner of the combo box is responsible for drawing an image by creating the combo box as an owner-draw control. When you use CComboBoxEx, you do not need to set the drawing styles CBS_OWNERDRAWFIXED and CBS_HASSTRINGS because they are implied. Otherwise, you must write code to perform drawing operations. A CComboBoxEx control supports up to three images per item: one for a selected state, one for an unselected state, and one for an overlay image.

Styles

CComboBoxEx supports the styles CBS_SIMPLE, CBS_DROPDOWN, CBS_DROPDOWNLIST, and WS_CHILD. All other styles passed when you create the window are ignored by the control. After the window is created, you can provide other combo box styles by calling the CComboBoxEx member function SetExtendedStyle. With these styles, you can:

  • Set string searches in the list to be case-sensitive.

  • Create a combo box control that uses the slash ('/'), backslash ('\'), and period ('.') characters as word delimiters. This allow users to jump from word to word, using the keyboard shortcut CTRL+ ARROW.

  • Set the combo box control to either display or not display an image. If no image is displayed, the combo box can remove the text indent that accommodates an image.

  • Create a narrow combo box control, including sizing it so it clips the wider combo box it contains.

These style flags are described further in Using CComboBoxEx.

Item Retention and Callback Item Attributes

Item information, such as indexes for items and images, indentation values, and text strings, is stored in the Win32 structure COMBOBOXEXITEM, as described in the Windows SDK. The structure also contains members that correspond to callback flags.

For a detailed, conceptual discussion, see Using CComboBoxEx.

Inheritance Hierarchy

CObject

CCmdTarget

CWnd

CComboBox

CComboBoxEx

Requirements

Header: afxcmn.h

See Also

Reference

CComboBox Class

Hierarchy Chart

CComboBox Class

Concepts

MFC Sample MFCIE