ComboBox
The combo box is an edit field with an associated drop down list box to select from. Note that ComboBox itself is a subclass of Edit that has a child ListBox window. That is, what is really to the user a single ComboBox is actually an edit field and a list field that communicate with eachother. The dropdown is enacted by the user by pressing <Alt+DownArrow>. ComboBox has an option to provide for selection only (i.e. no free form text entry of the edit field); this option corresponds to the CUA drop-down list.
Note: With a ComboBox in a Dialog Box, you should reserve a ListBox window in the array of dialog window, immediately after the ComboBox window itself. Although the ComboBox itself allows the attached Listboxes to be anywhere in the application's data segment (as pointed to by the Menu field), the Dialog Box handler assumes the listbox immediately follows the combobox in the array of window controls.
Window Structure Details
- int x,y,w,h: Used by the Edit subclass; refer to Edit for details.
- PLHRES Title: Used by the Edit subclass; refer to Edit for details.
- PLHDATA Data: Used by the Edit subclass; refer to Edit for details.
- UINT LogicalSize: Used by the Edit subclass; refer to Edit for details.
- UINT Style: If the COMBO_NOEDIT is bit set, the user can only change the text of the Edit box by selecting an entry from the ListBox, not by editing.
- PLHWINDOW Parent: Used by the Edit subclass; refer to Edit for details.
- PLHFKEYS FKeys;: Used by the Edit subclass; refer to Edit for details.
- PLHMENU Menu: Menu is a pointer to the ListBox window structure to be created when <Alt+DownArrow> is pressed. The fields of the ListBox that are automatically filled in by the ComboBox handler are x, y, Parent, Title, and Style. The application should fill in the w, h, Data and LogicalSize fields of the ListBox window structure.
- UINT Selection: Used by the Edit subclass; refer to Edit for details.
- UINT WindowTop: Used by the Edit subclass; refer to Edit for details.
Messages
- KEYSTROKE: Responds to the following keys:
- ESC: If the list box is currently shown, ComboBox sends it a DISAPPEAR message. Otherwise, ComboBox sends the key to the Edit class handler (see Edit for further details), and ListBox is sent a NOTIFY_UPDATE to reposition itself.
- Up Arrow, Down Arrow, PgUp, or PgDn send the keystrokes to the associated ListBox. ComboBox changes the text of the Edit field to reflect the newly selected (highlighted) item.
- Alt+DownArrow sends the ListBox an APPEAR message.
- Alt+UpArrow sends the ListBox a DISAPPEAR message.
- Home, End: If the style COMBO_NOEDIT is set, ComboBox sends the key to the associated ListBox handler. If it is not set, the Edit subclass handler processes the key.
- All other keys: If the style COMBO_NOEDIT is set, ComboBox sends the key to the associated ListBox handler. If it is not set, the Edit subclass handler processes the key, and ComboBox sends the ListBox a NOTIFY_UPDATE to reposition itself.
- DRAW:
The ComboBox handler displays the Edit field, and displays the Underlined Arrow icon to the field's right.
- CREATE:
ComboBox sends the CREATE message to the Edit class handler. The ComboBox handler automatically adjusts the ListBox (pointed to by the Menu field) by: Style |= STYLE_NOTIFY | STYLE_INVISIBLE | STYLE_SAVEUNDER; Title = NULL; Parent = ComboBox; x = Left justified with edit field; y = Directly underneath edit field; ComboBox sends a NOTIFY message with the NOTIFY_UPDATE submessage to the ListBox class to position it's list to the element corresponding to the current edit field.
- LOSEFOCUS: The ComboBox handler sends the list child a DISAPPEAR message to become invisible.
- NOTIFY: If the submessage is NOTIFY_CHILDCHANGED, the ComboBox updates the Edit field to the newly selected line in the ListBox.
- DESTROY: ComboBox destroys the attached ListBox, then destroys itself.
- APPEAR: ComboBox converts the window size (w,h) fields when STYLE_WHCHAR is being used. The ComboBox handler then passes the message to the Edit class handler.
- DISAPPEAR: ComboBox converts the window size (w,h) fields when STYLE_WHCHAR is being used. ComboBox then passes the message to the Edit class handler.
- SETFOCUS: Passed to Edit class handler.
- NULLEVENT: Passed to Edit class handler.
- TERMINATE: Passed to Edit class handler.
- ACTIVATE: Passed to Edit class handler.
- DEACTIVATE: Passed to Edit class handler.
- COMMAND: Passed to Edit class handler.