UDF > GUI > GuiComboBoxEx >


_GUICtrlComboBoxEx_Create

Cr�e un contr�le ComboBoxEx

#include <GuiComboBoxEx.au3>
_GUICtrlComboBoxEx_Create ( $hWnd, $sText, $iX, $iY [, $iWidth = 100 [, $iHeight = 200 [, $iStyle = 0x00200002 [, $iExStyle = 0x00000000]]]] )

Param�tres

$hWnd Handle du parent ou du propri�taire de la fen�tre
$sText Texte d�limit� � ajouter � la ComboBox
$iX Position horizontale du contr�le
$iY Position verticale du contr�le
$iWidth [optionnel] Largeur du contr�le
$iHeight [optionnel] Hauteur du contr�le
$iStyle [optionnel] Style du contr�le:
    $CBS_DROPDOWN - Similaire � $CBS_SIMPLE, sauf que la liste n'est pas affich�e � moins que l'utilisateur s�lectionne une ic�ne � c�t� du champ de saisie
    $CBS_DROPDOWNLIST - Similaire � $CBS_DROPDOWN, sauf que le contr�le d'�dition est remplac� par un �l�ment de texte statique qui affiche la s�lection actuelle dans la zone de liste
    $CBS_SIMPLE - Affiche la liste d�roulante tout le temps

Default: $CBS_DROPDOWN, $WS_VSCROLL
Forced: $WS_CHILD, $WS_TABSTOP, $WS_VISIBLE
$iExStyle [optionnel] Style �tendu du contr�le:
    $CBES_EX_CASESENSITIVE - Les recherches dans la liste seront sensibles � la casse
    $CBES_EX_NOEDITIMAGE - La zone d'�dition et la liste d�roulante n'affichent pas les �l�ments images
    $CBES_EX_NOEDITIMAGEINDENT - La zone d'�dition et la liste d�roulante n'affichent pas les �l�ments images
    $CBES_EX_NOSIZELIMIT - Permet au contr�le ComboBoxEx d'�tre dimensionn� verticalement plus petit que le contr�le de liste d�roulante qu'il contient

Valeur de retour

Succ�s: Retourne le handle du contr�le ComboBoxEx.
�chec: Retourne 0.

En relation

_GUICtrlComboBoxEx_Destroy

Exemple

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $g_hCombo

Example()

Func Example()
    Local $hGUI

    ; Cr�e une GUI
    $hGUI = GUICreate("ComboBoxEx Create", 400, 300)
    $g_hCombo = _GUICtrlComboBoxEx_Create($hGUI, "This is a test|Line 2", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    _GUICtrlComboBoxEx_AddString($g_hCombo, "Some More Text")
    _GUICtrlComboBoxEx_InsertString($g_hCombo, "Inserted Text", 1)

    ; Boucle jusqu'� ce que l'utilisateur quitte
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $tInfo

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $g_hCombo
            Switch $iCode
                Case $CBEN_BEGINEDIT ; Envoy� quand l'utilisateur active la liste d�roulante ou clique dans le champ de saisie du contr�le.
                    _DebugPrint("$CBEN_BEGINEDIT" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                            "-->Code:" & @TAB & $iCode)
                    Return 0
                Case $CBEN_DELETEITEM
                    _DebugPrint("$CBEN_DELETEITEM" & _GetComboBoxEx($lParam))
                    Return 0
                Case $CBEN_DRAGBEGINA, $CBEN_DRAGBEGINW
                    $tInfo = DllStructCreate($tagNMCBEDRAGBEGIN, $lParam)
                    If DllStructGetData($tInfo, "ItemID") Then _DebugPrint("$CBEN_DRAGBEGIN" & _GetComboBoxEx($lParam))
                    _DebugPrint("$CBEN_DRAGBEGIN" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tInfo, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tInfo, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tInfo, "Code") & @CRLF & _
                            "-->ItemID:" & @TAB & DllStructGetData($tInfo, "ItemID") & @CRLF & _
                            "-->Text:" & @TAB & DllStructGetData($tInfo, "Text"))
                    ; return est ignor�
                Case $CBEN_ENDEDITA, $CBEN_ENDEDITW ; Envoy� quand l'utilisateur a termin� une op�ration dans la zone d'�dition ou a s�lectionn� un �l�ment dans la liste d�roulante du contr�le.
                    $tInfo = DllStructCreate($tagNMCBEENDEDIT, $lParam)
                    _DebugPrint("$CBEN_ENDEDIT" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tInfo, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tInfo, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tInfo, "Code") & @CRLF & _
                            "-->fChanged:" & @TAB & DllStructGetData($tInfo, "fChanged") & @CRLF & _
                            "-->NewSelection:" & @TAB & DllStructGetData($tInfo, "NewSelection") & @CRLF & _
                            "-->Text:" & @TAB & DllStructGetData($tInfo, "Text") & @CRLF & _
                            "-->Why:" & @TAB & DllStructGetData($tInfo, "Why"))
                   Return False ; accept the notification and allow the control to display the selected item
                    ; Return True  ; otherwise
                Case $CBEN_GETDISPINFOA, $CBEN_GETDISPINFOW ; Envoy� pour r�cup�rer des informations d'affichage sur un �l�ment callback
                    _DebugPrint("$CBEN_GETDISPINFO" & _GetComboBoxEx($lParam))
                    Return 0
                Case $CBEN_INSERTITEM
                    $tInfo = DllStructCreate($tagNMCOMBOBOXEX, $lParam)
                    Local $tBuffer = DllStructCreate("wchar Text[" & DllStructGetData($tInfo, "TextMax") & "]", DllStructGetData($tInfo, "Text"))
                    _DebugPrint("$CBEN_INSERTITEM" & @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tInfo, "hWndFrom") & @CRLF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tInfo, "IDFrom") & @CRLF & _
                            "-->Code:" & @TAB & DllStructGetData($tInfo, "Code") & @CRLF & _
                            "-->Mask:" & @TAB & DllStructGetData($tInfo, "Mask") & @CRLF & _
                            "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
                            "-->Text:" & @TAB & DllStructGetData($tBuffer, "Text") & @CRLF & _
                            "-->TextMax:" & @TAB & DllStructGetData($tInfo, "TextMax") & @CRLF & _
                            "-->Indent:" & @TAB & DllStructGetData($tInfo, "Indent") & @CRLF & _
                            "-->Image:" & @TAB & DllStructGetData($tInfo, "Image") & @CRLF & _
                            "-->SelectedImage:" & @TAB & DllStructGetData($tInfo, "SelectedImage") & @CRLF & _
                            "-->OverlayImage:" & @TAB & DllStructGetData($tInfo, "OverlayImage") & @CRLF & _
                            "-->Param:" & @TAB & DllStructGetData($tInfo, "Param"))
                    Return 0
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _GetComboBoxEx($lParam)
    Local $tInfo = DllStructCreate($tagNMCOMBOBOXEX, $lParam)
    Local $aItem = _GUICtrlComboBoxEx_GetItem($g_hCombo, DllStructGetData($tInfo, "Item"))
    Return @CRLF & "--> hWndFrom:" & @TAB & DllStructGetData($tInfo, "hWndFrom") & @CRLF & _
            "-->IDFrom:" & @TAB & DllStructGetData($tInfo, "IDFrom") & @CRLF & _
            "-->Code:" & @TAB & DllStructGetData($tInfo, "Code") & @CRLF & _
            "-->Mask:" & @TAB & DllStructGetData($tInfo, "Mask") & @CRLF & _
            "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
            "-->Text:" & @TAB & $aItem[0] & @CRLF & _
            "-->TextMax:" & @TAB & $aItem[1] & @CRLF & _
            "-->Indent:" & @TAB & $aItem[2] & @CRLF & _
            "-->Image:" & @TAB & $aItem[3] & @CRLF & _
            "-->SelectedImage:" & @TAB & $aItem[4] & @CRLF & _
            "-->OverlayImage:" & @TAB & $aItem[5] & @CRLF & _
            "-->Param:" & @TAB & $aItem[5]
EndFunc   ;==>_GetComboBoxEx

Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
    ConsoleWrite( _
            "!===========================================================" & @CRLF & _
            "+======================================================" & @CRLF & _
            "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
            "+======================================================" & @CRLF)
EndFunc   ;==>_DebugPrint