Purpose |
Add a list box control to a dialog. A list box contains a set of predefined
entries that permit a user to select one or more items. A list box may
contain
| ||||||||||||||||||||||||||||||
Syntax |
CONTROL ADD LISTBOX, hDlg, id&, [items$()], x, y, xx, yy [, [style&] [, [exstyle&]]] [[,] CALL callback] | ||||||||||||||||||||||||||||||
hDlg |
Handle of the dialog in which the list 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 %PickList 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 list box. Items are copied from the array to the list 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. Also see Restrictions below. To create a list box that is initially empty, either omit this parameter, or specify an array whose first element contains an empty string. If the list box uses the %LBS_SORT style, the items are sorted alphanumerically as they are added to the list 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 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 list box control. The default list box style comprises %LBS_SORT, %LBS_NOTIFY, %WS_TABSTOP, and %WS_VSCROLL (along with the %WS_EX_CLIENTEDGE extended style). The default list box style is used if both the primary and extended style parameters are omitted from the statement. For example: CONTROL ADD LISTBOX, hDlg, id&, items$(), 100, 100, 150, 200, , , _ CALL ListboxCallback() ' 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 list 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 list box control. The default extended list box style comprises %WS_EX_CLIENTEDGE, and %WS_EX_LEFT. The default extended style is used if both the primary and extended parameters are omitted from the CONTROL ADD LISTBOX statement, in the same manner as style& above. The extended list 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 %WM_COMMAND messages for the control. If a callback for the control is not designated, you must create a Callback Function for the dialog to process notification messages from your list box. If the 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 |
The following notifications are sent to the Callback Function:
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. | ||||||||||||||||||||||||||||||
Restrictions |
Under Windows 95/98/ME, a list box is limited to 32,736 items. In all versions of Windows, the actual string data contained by the list box is limited only by available memory. | ||||||||||||||||||||||||||||||
See also |
Dynamic Dialog Tools, LISTBOX ADD, LISTBOX DELETE, LISTBOX GET TEXT, LISTBOX RESET, LISTBOX SELECT |
Do not intermix list box styles with similarly named combo box styles as the numeric values of similar styles can produce unexpected results. For example, %LBS_SORT =&H2 and %CBS_SORT = &H100. List box styles are prefixed with %LBS. |