Combo boxes
A combo box consists of a list and a selection field. The list presents the
options that a user can select and the selection field displays the current
selection. Except in drop-down list boxes, the selection field is an edit
control and can be used to enter text not available in the list.
Combo boxes can be characterized by type and style. Combo box types determine
whether the combo box list is a drop-down list and whether the selection field
is an edit control. A drop-down list appears only when the user opens it, so it
uses less screen space than a list that is always visible. If the selection
field is an edit control, the user can enter information not available in the
list; otherwise, the user can only select items in the list.
The following table shows the three combo box types and indicates their
drop-down list and edit control attributes.
| Combo box type |
Drop-down list |
Edit control |
| Drop-down combo box |
Yes |
Yes |
| Drop-down list box |
Yes |
No |
| Simple combo box |
No |
Yes |
Combo box styles define specific properties of a combo box. You can combine
styles; however some styles only apply to certain combo box types.
Styles
- No height adjust.Specifies that the size of the combo box is
exactly the size specified by the application when it created the combo box.
Normally, the system sizes a combo box so that it does not display partial
items.
- Local memory. Specifies that an owner-drawn combo box contains
items consisting of strings. The combo box maintains the memory and address
for the strings so the application can use the
CB_GETLBTEXT
message to retrieve the text for a particular item.
- DOS char convertion.Converts text entered in the combo box edit
control from the Windows character set to the OEM character set and then
back to the Windows character set. This ensures proper character conversion
when the application calls the
CharToOem
function to convert a Windows string in the combo box to OEM characters.
This style is most useful for combo boxes that contain file names and
applies only to combo boxes created with the CBS_SIMPLE or CBS_DROPDOWN
style.
- Owner draw fixed.Specifies that the owner of the list box is
responsible for drawing its contents and that the items in the list box are
all the same height. The owner window receives a
WM_MEASUREITEM
message when the combo box is created and a
WM_DRAWITEM
message when a visual aspect of the combo box has changed.
- Owner draw variable.Specifies that the owner of the list box is
responsible for drawing its contents and that the items in the list box are
variable in height. The owner window receives a WM_MEASUREITEM
message for each item in the combo box when you create the combo box and a WM_DRAWITEM
message when a visual aspect of the combo box has changed.
- Auto hscroll. Automatically scrolls the text in an edit control to
the right when the user types a character at the end of the line. If this
style is not set, only text that fits within the rectangular boundary is
allowed.