Function Reference


_GUICtrlComboBox_Create

Create a ComboBox control

#include <GuiComboBox.au3>
_GUICtrlComboBox_Create ( $hWnd, $sText, $iX, $iY [, $iWidth = 100 [, $iHeight = 120 [, $iStyle = 0x00200042 [, $iExStyle = 0x00000000]]]] )

Parameters

$hWnd Handle to parent or owner window
$sText Delimited string to add to the combobox
$iX Horizontal position of the control
$iY Vertical position of the control
$iWidth [optional] Control width
$iHeight [optional] Control height
$iStyle [optional] Control style:
    $CBS_AUTOHSCROLL - Automatically scrolls the text in an edit control to the right when the user types a character at the end of the line.
    $CBS_DISABLENOSCROLL - Shows a disabled vertical scroll bar
    $CBS_DROPDOWN - Similar to $CBS_SIMPLE, except that the list box is not displayed unless the user selects an icon next to the edit control
    $CBS_DROPDOWNLIST - Similar to $CBS_DROPDOWN, except that the edit control is replaced by a static text item that displays the current selection in the list box
    $CBS_LOWERCASE - Converts to lowercase all text in both the selection field and the list
    $CBS_NOINTEGRALHEIGHT - Specifies that the size of the combo box is exactly the size specified by the application when it created the combo box
    $CBS_OEMCONVERT - Converts text entered in the combo box edit control from the Windows character set to the OEM character set and then back to the Windows character set
    $CBS_OWNERDRAWFIXED - Specifies that the owner of the list box is responsible for drawing its contents and that the items in the list box are all the same height
    $CBS_OWNERDRAWVARIABLE - Specifies that the owner of the list box is responsible for drawing its contents and that the items in the list box are variable in height
    $CBS_SIMPLE - Displays the list box at all times
    $CBS_SORT - Automatically sorts strings added to the list box
    $CBS_UPPERCASE - Converts to uppercase all text in both the selection field and the list

Default: $CBS_DROPDOWN, $CBS_AUTOHSCROLL, $WS_VSCROLL
Forced : $WS_CHILD, $WS_TABSTOP, $WS_VISIBLE
$iExStyle [optional] Control extended style. These correspond to the standard $WS_EX_* constants. See Extended Style Table.

Return Value

Success: the handle to the Listbox control.
Failure: 0.

Remarks

This function is for Advanced users and for learning how the control works.

Related

_GUICtrlComboBox_Destroy

Example

Example : Created with UDF

#include <Extras\WM_NOTIFY.au3>
#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Global $g_hCombo

Example()

Func Example()
        ; Create GUI
        Local $hGUI = GUICreate("ComboBox Create (v" & @AutoItVersion & ")", 400, 296)
        $g_hCombo = _GUICtrlComboBox_Create($hGUI, "", 2, 2, 396, 296)
        GUISetState(@SW_SHOW)

        ; Add files
        _GUICtrlComboBox_BeginUpdate($g_hCombo)
        _GUICtrlComboBox_AddDir($g_hCombo, "", $DDL_DRIVES, False)
        _GUICtrlComboBox_EndUpdate($g_hCombo)

        GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

        ; Loop until the user exits.
        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE
        GUIDelete()
EndFunc   ;==>Example

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
        #forceref $hWnd, $iMsg
        Local $hWndFrom = $lParam
        Local $iIDFrom = BitAND($wParam, 0xFFFF) ; Low Word
        Local $iCode = BitShift($wParam, 16) ; Hi Word
        Switch $hWndFrom
                Case $g_hCombo
                        Switch $iCode
                                Case $CBN_CLOSEUP ; Sent when the list box of a combo box has been closed
                                        _WM_NOTIFY_DebugInfo("$CBN_CLOSEUP", "hWndFrom,IDFrom", $hWndFrom, $iIDFrom)
                                        ; no return value
                                Case $CBN_DBLCLK ; Sent when the user double-clicks a string in the list box of a combo box
                                        _WM_NOTIFY_DebugInfo("$CBN_DBLCLK", "hWndFrom,IDFrom", $hWndFrom, $iIDFrom)
                                        ; no return value
                                Case $CBN_DROPDOWN ; Sent when the list box of a combo box is about to be made visible
                                        _WM_NOTIFY_DebugInfo("$CBN_DROPDOWN", "hWndFrom,IDFrom", $hWndFrom, $iIDFrom)
                                        ; no return value
                                Case $CBN_EDITCHANGE ; Sent after the user has taken an action that may have altered the text in the edit control portion of a combo box
                                        _WM_NOTIFY_DebugInfo("$CBN_EDITCHANGE", "hWndFrom,IDFrom", $hWndFrom, $iIDFrom)
                                        ; no return value
                                Case $CBN_EDITUPDATE ; Sent when the edit control portion of a combo box is about to display altered text
                                        _WM_NOTIFY_DebugInfo("$CBN_EDITUPDATE", "hWndFrom,IDFrom", $hWndFrom, $iIDFrom)
                                        ; no return value
                                Case $CBN_ERRSPACE ; Sent when a combo box cannot allocate enough memory to meet a specific request
                                        _WM_NOTIFY_DebugInfo("$CBN_ERRSPACE", "hWndFrom,IDFrom", $hWndFrom, $iIDFrom)
                                        ; no return value
                                Case $CBN_KILLFOCUS ; Sent when a combo box loses the keyboard focus
                                        _WM_NOTIFY_DebugInfo("$CBN_KILLFOCUS", "hWndFrom,IDFrom", $hWndFrom, $iIDFrom)
                                        ; no return value
                                Case $CBN_SELCHANGE ; Sent when the user changes the current selection in the list box of a combo box
                                        _WM_NOTIFY_DebugInfo("$CBN_SELCHANGE", "hWndFrom,IDFrom", $hWndFrom, $iIDFrom)
                                        ; no return value
                                Case $CBN_SELENDCANCEL ; Sent when the user selects an item, but then selects another control or closes the dialog box
                                        _WM_NOTIFY_DebugInfo("$CBN_SELENDCANCEL", "hWndFrom,IDFrom", $hWndFrom, $iIDFrom)
                                        ; no return value
                                Case $CBN_SELENDOK ; Sent when the user selects a list item, or selects an item and then closes the list
                                        _WM_NOTIFY_DebugInfo("$CBN_SELENDOK", "hWndFrom,IDFrom", $hWndFrom, $iIDFrom)
                                        ; no return value
                                Case $CBN_SETFOCUS ; Sent when a combo box receives the keyboard focus
                                        _WM_NOTIFY_DebugInfo("$CBN_SETFOCUS", "hWndFrom,IDFrom", $hWndFrom, $iIDFrom)
                                        ; no return value
                        EndSwitch
                EndSwitch
        Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND