Bei einer GUICtrlComboBoxEx eine GUICtrlSetOnEvent Funktion einbauen?

  • Hallo Autoit.de Community!

    Habe folgendes Problem..
    Ich programmiere seit einer Weile an meinem neuen Skript Aut OS rum...
    Jetzt hab ich die Ausschalt Combo (Guictrlcreatecombo) mit einer GUICtrlComboBoxEx ersetzt...
    Warum funktioniert jetzt nicht mehr Guictrlsetonevent?
    Screenshot im Anhang ;)

    Spoiler anzeigen
    [autoit]

    Func _GUI_Exit()
    $_GUI_Exit = GUICreate("Beenden", 139, 23, $Width-(139+10), $Height-(23*2+10), BitOR($WS_CAPTION,$WS_POPUP,$WS_BORDER,$WS_CLIPSIBLINGS), BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
    GUISetBkColor( $BG_Color )
    Global $_FGUI_Exit_Combo_Exit = _GUICtrlComboBoxEx_Create ($_GUI_Exit, "", 0, 0, 139, 100, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
    GUICtrlSetOnEvent(-1,"_FGUI_Exit_Combo_Exit")

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    $nExStyle = DllCall("user32.dll", "int", "GetWindowLong", "hwnd",$_GUI_Exit, "int", 0xEC)
    DllCall("user32.dll", "int", "SetWindowLong", "hwnd", $_GUI_Exit, "int", 0xEC, "int", BitOR($nExStyle[0], $WS_EX_MDICHILD))
    DllCall("user32.dll", "int", "SetParent", "hwnd", $_GUI_Exit, "hwnd", $hGUI)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    $hImage = _GUIImageList_Create (16, 16, 5, 3)
    For $x = 0 To 146
    _GUIImageList_AddIcon ($hImage, @SystemDir & "\shell32.dll", $x)
    Next
    _GUIImageList_Add ($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap ($_FGUI_Exit_Combo_Exit, 0xFF0000, 16, 16))
    _GUIImageList_Add ($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap ($_FGUI_Exit_Combo_Exit, 0x00FF00, 16, 16))
    _GUIImageList_Add ($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap ($_FGUI_Exit_Combo_Exit, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList ($_FGUI_Exit_Combo_Exit, $hImage)

    [/autoit] [autoit][/autoit] [autoit]

    _GUICtrlComboBoxEx_InitStorage ($_FGUI_Exit_Combo_Exit, 150, 300)

    [/autoit] [autoit][/autoit] [autoit]

    _GUICtrlComboBoxEx_BeginUpdate ($_FGUI_Exit_Combo_Exit)

    [/autoit] [autoit][/autoit] [autoit]

    _GUICtrlComboBoxEx_AddString ($_FGUI_Exit_Combo_Exit,"1 Benutzer abmelden",44,44)
    _GUICtrlComboBoxEx_AddString ($_FGUI_Exit_Combo_Exit,"3 Programm beenden...",27,27)

    [/autoit] [autoit][/autoit] [autoit]

    _GUICtrlComboBoxEx_EndUpdate ($_FGUI_Exit_Combo_Exit)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _FGUI_Exit_Combo_Exit()
    MsgBox(1,"","test")
    If StringLeft(_GUICtrlComboBoxEx_GetEditText($_FGUI_Exit_Combo_Exit),1) = "1" Then

    [/autoit] [autoit][/autoit] [autoit]

    ElseIf StringLeft(_GUICtrlComboBoxEx_GetEditText($_FGUI_Exit_Combo_Exit),1) = "3" Then
    _exit()
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit]

    Danke im Voraus

    mfg. Andi

    • Offizieller Beitrag

    Ich denke du meinst _GUICtrlComboBoxEx_Create , bei dieser UDF- Funktion kannst du nicht GUICtrlSetOnEvent arbeiten.
    Alle Ereignisse werden Innerhalb der WM_NOTIFY Funktion abgefragt, schau dir mal das Beispiel zu _GUICtrlComboBoxEx_Create an.

  • Ich hab das jetzt gemacht...
    aber irngdwie versteh ich das nicht... im Beispiel gibt er es aus wenn ich auf eine Combo klicke... hier jedoch überhaupt nicht

    Spoiler anzeigen

    !===========================================================
    +======================================================
    -->Line(0278): $CBEN_INSERTITEM
    --> hWndFrom: 0x00050A04
    -->IDFrom: 10000
    -->Code: -801
    -->Mask: 39
    -->Item: -1
    -->Text: 1 Benutzer abmelden
    -->TextMax: 40
    -->Indent: -1
    -->Image: 44
    -->SelectedImage: 44
    -->OverlayImage: -1
    -->Param: 0
    +======================================================
    !===========================================================
    +======================================================
    -->Line(0278): $CBEN_INSERTITEM
    --> hWndFrom: 0x00050A04
    -->IDFrom: 10000
    -->Code: -801
    -->Mask: 39
    -->Item: -1
    -->Text: 3 Programm beenden...
    -->TextMax: 44
    -->Indent: -1
    -->Image: 27
    -->SelectedImage: 27
    -->OverlayImage: -1
    -->Param: 1
    +======================================================


    Autoit Code:

    Spoiler anzeigen
    [autoit]

    Func _GUI_Exit()
    $Debug_CB = False
    Global $_GUI_Exit = GUICreate("Beenden", 139, 23, $Width-(139+10), $Height-(23*2+10), BitOR($WS_CAPTION,$WS_POPUP,$WS_BORDER,$WS_CLIPSIBLINGS), BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
    GUISetBkColor( $BG_Color )
    Global $_FGUI_Exit_Combo_Exit = _GUICtrlComboBoxEx_Create ($_GUI_Exit, "", 0, 0, 139, 100, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
    GUICtrlSetOnEvent(-1,"_FGUI_Exit_Combo_Exit")

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    $nExStyle = DllCall("user32.dll", "int", "GetWindowLong", "hwnd",$_GUI_Exit, "int", 0xEC)
    DllCall("user32.dll", "int", "SetWindowLong", "hwnd", $_GUI_Exit, "int", 0xEC, "int", BitOR($nExStyle[0], $WS_EX_MDICHILD))
    DllCall("user32.dll", "int", "SetParent", "hwnd", $_GUI_Exit, "hwnd", $hGUI)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    GUISetState()
    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

    [/autoit] [autoit][/autoit] [autoit]

    $hImage = _GUIImageList_Create (16, 16, 5, 3)
    For $x = 0 To 146
    _GUIImageList_AddIcon ($hImage, @SystemDir & "\shell32.dll", $x)
    Next
    _GUIImageList_Add ($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap ($_FGUI_Exit_Combo_Exit, 0xFF0000, 16, 16))
    _GUIImageList_Add ($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap ($_FGUI_Exit_Combo_Exit, 0x00FF00, 16, 16))
    _GUIImageList_Add ($hImage, _GUICtrlComboBoxEx_CreateSolidBitMap ($_FGUI_Exit_Combo_Exit, 0x0000FF, 16, 16))
    _GUICtrlComboBoxEx_SetImageList ($_FGUI_Exit_Combo_Exit, $hImage)

    [/autoit] [autoit][/autoit] [autoit]

    _GUICtrlComboBoxEx_InitStorage ($_FGUI_Exit_Combo_Exit, 150, 300)

    [/autoit] [autoit][/autoit] [autoit]

    _GUICtrlComboBoxEx_BeginUpdate ($_FGUI_Exit_Combo_Exit)

    [/autoit] [autoit][/autoit] [autoit]

    _GUICtrlComboBoxEx_AddString ($_FGUI_Exit_Combo_Exit,"1 Benutzer abmelden",44,44)
    _GUICtrlComboBoxEx_AddString ($_FGUI_Exit_Combo_Exit,"3 Programm beenden...",27,27)

    [/autoit] [autoit][/autoit] [autoit]

    _GUICtrlComboBoxEx_EndUpdate ($_FGUI_Exit_Combo_Exit)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _FGUI_Exit_Combo_Exit()
    MsgBox(1,"","test")
    If StringLeft(_GUICtrlComboBoxEx_GetEditText($_FGUI_Exit_Combo_Exit),1) = "1" Then

    [/autoit] [autoit][/autoit] [autoit]

    ElseIf StringLeft(_GUICtrlComboBoxEx_GetEditText($_FGUI_Exit_Combo_Exit),1) = "3" Then
    _exit()
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR

    [/autoit] [autoit][/autoit] [autoit]

    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
    Case $_FGUI_Exit_Combo_Exit
    Switch $iCode
    Case $CBEN_BEGINEDIT ; Sent when the user activates the drop-down list or clicks in the control's edit box.
    _DebugPrint("$CBEN_BEGINEDIT" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
    "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
    "-->Code:" & @TAB & $iCode)
    Return 0
    Case $CBEN_DELETEITEM
    _DebugPrint("$CBEN_DELETEITEM" & _GetComboBoxEx($ilParam))
    Return 0
    Case $CBEN_DRAGBEGINA, $CBEN_DRAGBEGINW
    Local $tInfo = DllStructCreate($tagNMCBEDRAGBEGIN, $ilParam)
    If DllStructGetData($tInfo, "ItemID") Then _DebugPrint("$CBEN_DRAGBEGIN" & _GetComboBoxEx($ilParam))
    _DebugPrint("$CBEN_DRAGBEGIN" & @LF & "--> hWndFrom:" & @TAB & DllStructGetData($tInfo, "hWndFrom") & @LF & _
    "-->IDFrom:" & @TAB & DllStructGetData($tInfo, "IDFrom") & @LF & _
    "-->Code:" & @TAB & DllStructGetData($tInfo, "Code") & @LF & _
    "-->ItemID:" & @TAB & DllStructGetData($tInfo, "ItemID") & @LF & _
    "-->Text:" & @TAB & DllStructGetData($tInfo, "Text"))
    ; return is ignored
    Case $CBEN_ENDEDITA, $CBEN_ENDEDITW ; Sent when the user has concluded an operation within the edit box or has selected an item from the control's drop-down list.
    Local $tInfo = DllStructCreate($tagNMCBEENDEDIT, $ilParam)
    _DebugPrint("$CBEN_ENDEDIT" & @LF & "--> hWndFrom:" & @TAB & DllStructGetData($tInfo, "hWndFrom") & @LF & _
    "-->IDFrom:" & @TAB & DllStructGetData($tInfo, "IDFrom") & @LF & _
    "-->Code:" & @TAB & DllStructGetData($tInfo, "Code") & @LF & _
    "-->fChanged:" & @TAB & DllStructGetData($tInfo, "fChanged") & @LF & _
    "-->NewSelection:" & @TAB & DllStructGetData($tInfo, "NewSelection") & @LF & _
    "-->Text:" & @TAB & DllStructGetData($tInfo, "Text") & @LF & _
    "-->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 ; Sent to retrieve display information about a callback item
    _DebugPrint("$CBEN_GETDISPINFO" & _GetComboBoxEx($ilParam))
    Return 0
    Case $CBEN_INSERTITEM
    Local $tInfo = DllStructCreate($tagNMCOMBOBOXEX, $ilParam)
    Local $tBuffer = DllStructCreate("wchar Text[" & DllStructGetData($tInfo, "TextMax") & "]", DllStructGetData($tInfo, "Text"))
    _DebugPrint("$CBEN_INSERTITEM" & @LF & "--> hWndFrom:" & @TAB & DllStructGetData($tInfo, "hWndFrom") & @LF & _
    "-->IDFrom:" & @TAB & DllStructGetData($tInfo, "IDFrom") & @LF & _
    "-->Code:" & @TAB & DllStructGetData($tInfo, "Code") & @LF & _
    "-->Mask:" & @TAB & DllStructGetData($tInfo, "Mask") & @LF & _
    "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @LF & _
    "-->Text:" & @TAB & DllStructGetData($tBuffer, "Text") & @LF & _
    "-->TextMax:" & @TAB & DllStructGetData($tInfo, "TextMax") & @LF & _
    "-->Indent:" & @TAB & DllStructGetData($tInfo, "Indent") & @LF & _
    "-->Image:" & @TAB & DllStructGetData($tInfo, "Image") & @LF & _
    "-->SelectedImage:" & @TAB & DllStructGetData($tInfo, "SelectedImage") & @LF & _
    "-->OverlayImage:" & @TAB & DllStructGetData($tInfo, "OverlayImage") & @LF & _
    "-->Param:" & @TAB & DllStructGetData($tInfo, "Param"))
    Return 0
    EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
    EndFunc ;==>WM_NOTIFY

    [/autoit] [autoit][/autoit] [autoit]

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

    [/autoit] [autoit][/autoit] [autoit]

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

    [/autoit]