ComboBox Control
The combobox control provides a combination text box and listbox. Three types of comboboxes are available - one where the list always shows and two where the list only shown when the control is clicked. With the two dropdown lists, one is editable and the other is not.

An item selected from the list appears in the textbox. Depending on how the application is programmed, users can edit existing items or create new items by typing in the textbox. In the case of the dropdownlist style, the textbox is disabled (works like a non-editable label). The list may contain strings and or images. One or more list items may be selected. Horizontal and vertical scrollbars are available to help view the list. Automatic sorting of items is provided.

Arguments
The Control Add statement is used to create all new controls. Here are the statement's arguments and any special significance to the combobox control.

Usage Notes
Some of these comments refer to the ComboBox-specific statement in the next section below.

The ComboBox is limited to 32,767 items.

Indexing is starts at 1 for all Control and ComboBox statements.

Item numbers and returned item numbers are long integers.

The textbox is initially empty and must be filled programmatically.

To change an item and sort the results, use Delete/Add instead of Set Text.

To add an item and sort the results, use Add instead of Insert.

ComboBox-Specific PowerBASIC Statements
PowerBASIC provides several statements specific to the combobox control. These allow the application to manage the content and display of the control.

See the Usage section above for information on how to use the values made available by these statements.

Messages, Notifications, Styles, and ExtSstyles
There are four types of named constants in the following table. All are pulled from the MSDN web site.

The first column contains control-specific named constants and the second column contains generic window named constants (combobox controls are windows).

Also, if the PowerBASIC Help file has an entry on the value, it is highlighted in yellow. If the value was noted in PowerBASIC Help as a default value, it is also shown in bold text.

In the values for notifications, descriptions starting with -n and -c refer to events received through the %wm_notify and %wm_command messages. By default, PowerBASIC controls can receive both of these messages.

   

And here is a short description of many of the named constants corresponding to notifications, styles, and extstyle - particularly those discussed in the PowerBASIC Help topics.

    %cbn_closeup           -c list box closed
    %cbn_dblclk            -c double-clicks list box
    %cbn_dropdown          -c before list is shown
    %cbn_editchange        -c change made in edit box
    %cbn_editupdate        -c before change made in edit box
    %cbn_errspace          -c memory allocation problem
    %cbn_killfocus         -c keyboard focus lost
    %cbn_selcancel         -c item selection canceled
    %cbn_selchange         -c selection about to change (mouse or arrow keys)
    %cbn_selendok          -c item selection accepted
    %cbn_setfocus          -c keyboard focus received
    %cbs_autohscroll       - auto scroll text right, wide text allowed
    %cbs_disablenoscroll   - show disabled vertical scrollbar, else autohide
    %cbs_dropdown          - display list only when down arrow selected
    %cbs_dropdownlist      - display non-editable label in lieu of textbox
    %cbs_hasstrings        - combobox contains strings
    %cbs_lowercase         - convert user input in textbox to lower case
    %cbs_nointegralheight  - use exact dimensions (partial display of lines)
    %cbs_simple            - always display list (selection in textbox)
    %cbs_sort              - automatically sort list 
    %cbs_uppercase         - convert user input in textbox to upper case
    %wm_compareitem        -  position of item in owner-drawn control
    %wm_drawitem           -  owner-drawn control has changed
    %wm_measureitem        -  owner-drawn control is created
    %ws_disabled           - initially disabled (no user input)
    %ws_ex_clientedge      - apply sunken edge border
    %ws_ex_left            - generic left-aligned properties
    %ws_ex_right           - generic right-aligned properties
    %ws_ex_staticedge      - apply 3D border
    %ws_ex_windowedge      - apply raised edge border
    %ws_group              - starts/ends group. use %ws_tabstop style.
    %ws_tabstop            - allows receipt of keyboard focus
    %ws_vscroll            - autodisplay vertical scroll

Callback Function
A control can have its own callback function, or use the parent dialog callback function.

A control callback function should return TRUE to indicate it has processed the message. This prevents unnecessarily calling the dialog callback function, which will process the message if no control callback function is available, or if the control callback function returns FALSE.

By default, both %WM_COMMAND and %WM_NOTIFY messages are received. However, if the #MESSAGE COMMAND compiler directive is invoked, the %WM_NOTIFY messages will not be available.

Here's a sample combobox control callback function.

   CallBack Function cbComboBox()
      Select Case CB.MSG
         Case %WM_COMMAND
            Select Case CB.CTLMSG
               Case %cbn_closeup
               Case %cbn_dblclk
               Case %cbn_dropdown
               Case %cbn_editchange
               Case %cbn_editupdate
               Case %cbn_errspace
               Case %cbn_killfocus
               Case %cbn_selchange
               Case %cbn_selcancel
               Case %cbn_selendok
               Case %cbn_setfocus
            End Selection
      End Select
   End Function

In each Case section, add the statements the application needs to respond to the event. Also, be sure to add "Function=1" as appropriate to indicate that the event was handled by the callback function.

Issues
Help mentions that comboboxes can contain images, but no information is provided on how to add the images. There are two samples apps distributed with PowerBASIC but with little explanation.

I'll update this page as more information becomes available.

CONTROL Statement Syntax
The following table lists the various Control statements (except the ADD statements). Most, but not all, can be used with the combobox control. A one-line description of the statement and then its syntax are presented.

If you have any suggestions or corrections, please let me know.