Function Reference


GUICtrlCreateCombo

Creates a ComboBox control for the GUI.

GUICtrlCreateCombo ( "text", left, top [, width [, height [, style = -1 [, exStyle = -1]]]] )

Parameters

text The text which will appear in the combo control.
left The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width [optional] The width of the control (default is the previously used width).
height [optional] The height of the control (default is the previously used height).
style [optional] Defines the style of the control. See GUI Control Styles Appendix.
    default (-1) : $CBS_DROPDOWN, $CBS_AUTOHSCROLL, $WS_VSCROLL
    forced style : $WS_TABSTOP
exStyle [optional] Defines the extended style of the control. See Extended Style Table.
    default ( -1) : $WS_EX_CLIENTEDGE

Return Value

Success: the identifier (controlID) of the new control.
Failure: 0.

Remarks

To obtain the value of the control see GUICtrlRead().
To set or change information in the control see GUICtrlUpdate...() functions.

Under Windows XP/2003 Windows will adjust the size of the opened combo. On other Windows versions you can define this size with the "height" parameter if the default value is not BIG enough to contain at least one line.

To combine styles with the default style use BitOR ( $GUI_SS_DEFAULT_COMBO, newstyle, ... ).
To use the values specified above you must #include <ComboConstants.au3> in your script.

Default resizing is $GUI_DOCKHEIGHT.

Related

GUICoordMode (Option), GUICtrlSetData, GUICtrlUpdate..., GUIGetMsg

Example

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Create a GUI with various controls.
    Local $hGUI = GUICreate("Example", 300, 200)

    ; Create a combobox control.
    Local $idComboBox = GUICtrlCreateCombo("Item 1", 10, 10, 185, 20)
    Local $idClose = GUICtrlCreateButton("Close", 210, 170, 85, 25)

    ; Add additional items to the combobox.
    GUICtrlSetData($idComboBox, "Item 2|Item 3", "Item 2")

    ; Display the GUI.
    GUISetState(@SW_SHOW, $hGUI)

    Local $sComboRead = ""

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idClose
                ExitLoop

            Case $idComboBox
                $sComboRead = GUICtrlRead($idComboBox)
                MsgBox($MB_SYSTEMMODAL, "", "The combobox is currently displaying: " & $sComboRead, 0, $hGUI)

        EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete($hGUI)
EndFunc   ;==>Example