Purpose |
Add a combo box to a dialog. A combo box is often used to allow a user
to select an item from a predefined list, or enter a fresh (unlisted)
item. A combo box may contain only text strings. To put numbers in a combo
box, convert them to
| |||||||||||||||||||||||||||||||||||||||||
Syntax |
CONTROL ADD COMBOBOX, hDlg, id&, [items$()], x, y, xx, yy [, [style&] [, [exstyle&]]] [[,] CALL callback] | |||||||||||||||||||||||||||||||||||||||||
hDlg |
Handle of the dialog in which the combo box will be created. The dialog will become the parent of the control. | |||||||||||||||||||||||||||||||||||||||||
id& |
Unique identifier for the control in the range 1 to 65535, frequently specified with numeric equates for clarity of the code. For example, the equate %StockNumberList is more informative than a literal value such as 497. Best practice suggests identifiers should start at 100 to avoid conflict with any of the standard predefined identifiers | |||||||||||||||||||||||||||||||||||||||||
items$() |
Optional dynamic (variable length) string array, containing the initial items to be displayed in the combo box. Items are copied from the array to the combo box, starting at the lowest subscript of the array (LBOUND), continuing on toward the end of the array, until an empty string is encountered, or the highest subscript is reached. If an array with an LBOUND of zero (the default) is specified, be sure that the 1st element (0) contains data. To create a combo box that is initially empty, either omit this parameter, or specify an array whose first element contains an empty string. If the combo box uses the %CBS_SORT style, the items are sorted alphanumerically as they are added to the combo box. | |||||||||||||||||||||||||||||||||||||||||
x, y |
| |||||||||||||||||||||||||||||||||||||||||
xx |
Integer expression, variable, or numeric literal value, specifying the width of the control. The width is given in the same terms (pixels or dialog units) as the parent dialog. The most common value used in the Microsoft Dialog Editor and Visual Studio is around 100 dialog units. | |||||||||||||||||||||||||||||||||||||||||
yy |
Integer expression, variable, or numeric literal value, specifying the height of the control. The height is given in the same terms (pixels or dialog units) as the parent dialog. The most common value used in the Microsoft Dialog Editor and Visual Studio is 40 dialog units. | |||||||||||||||||||||||||||||||||||||||||
style& |
Primary style of the control. There are three types of combo boxes: simple, dropdown, and dropdownlist. A simple combo box consists of a text box control and a list box; the list box is always displayed. A dropdown combo box consists of a text box control and a list box; the list box is not displayed unless the user clicks an icon. A dropdownlist combo box consists of a label control (not editable) and a list box; the list box is not displayed unless the user clicks an icon.
Note that some styles of combo box are mutually exclusive. In other words, you cannot combine certain styles that may conflict with one another. For example, you cannot specify %CBS_SIMPLE and %CBS_DROPDOWN at the same time. The default combo box style comprises %CBS_DROPDOWN, %CBS_SORT, and %WS_TABSTOP. The default style is used only if both the primary and extended style parameter values are omitted from the statement. For example: CONTROL ADD COMBOBOX, hDlg, id&, txt$(), 100, 100, 100, 40, , , CALL ComboCallback() ' Use default styles Custom style values replace the default values. That is, they are not additional to the default style values - your code must specify all necessary primary and extended style parameters. The primary combo box style value can be a combination of any values below, combined together with the OR operator to form a bitmask:
| |||||||||||||||||||||||||||||||||||||||||
exstyle& |
Extended style of the combo box control. The default extended combo box style comprises %WS_EX_LEFT, and %WS_EX_CLIENTEDGE. The default extended style is only used if both the primary and extended parameters are omitted from the CONTROL ADD COMBOBOX statement, in the same manner as style& above. The extended combo box style value can be a combination of any values below, combined together with the OR operator to form a bitmask:
| |||||||||||||||||||||||||||||||||||||||||
callback |
Optional name of a Callback Function to handle all %WM_COMMAND messages for the combo box. If a callback for the control is not designated, you must create a Callback Function for the dialog to process notification messages from your combo box. In general, when the control Callback Function processes a message, it should return TRUE (non-zero) to prevent the message being passed unnecessarily to the dialog callback (if one exists). The dialog callback should also return TRUE if the notification message is processed by that Callback Function. Otherwise, the DDT engine processes unhandled messages. | |||||||||||||||||||||||||||||||||||||||||
Remarks |
When the user selects an item or edits the text of a combo box, a message is sent to the Callback Function designated for the combo box. If there is no Callback Function designated then the message is sent to the callback for the dialog. If the control callback processes the notification message, it should return TRUE (non-zero) to prevent the message being passed needlessly to the dialog callback, and eventually to the DDT engine itself. Notification messages are sent to the Callback Function, with CBMSG = %WM_COMMAND, CBCTL holding the ID (id&) of the control, and CBCTLMSG holding the following values:
When a Callback Function receives a %WM_COMMAND message, it should explicitly test the value of CBCTL and CBCTLMSG to guarantee it is responding appropriately to the notification message. | |||||||||||||||||||||||||||||||||||||||||
See also |
Dynamic Dialog Tools, COMBOBOX ADD, COMBOBOX DELETE, COMBOBOX GET TEXT, COMBOBOX RESET, COMBOBOX SELECT |