GuictrlRebar fragen

  • Hallo,

    ich hatte mir mal die Reabr funktionen angeschaut aber irgendwie schaff ich es nicht, das z.b beim klicken auf dem speicherbutton z.b eine msgbox geöffnent wird.
    wie mach ich das?

    Spoiler anzeigen
    [autoit]

    #include <GuiReBar.au3>
    #include <GuiToolBar.au3>
    #include <GuiComboBox.au3>
    #include <GuiDateTimePicker.au3>
    #include <WindowsConstants.au3>
    #include <Constants.au3>
    #include <GuiConstantsEx.au3>

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

    Opt("MustDeclareVars", 1)

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

    $Debug_RB = False

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

    Global $hReBar

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

    _Main()

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

    Func _Main()
    Local $hgui, $btnExit, $hToolbar, $hCombo, $hDTP, $hInput
    Local Enum $idNew = 1000, $idOpen, $idSave, $idHelp

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

    $hgui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

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

    ; create the rebar control
    $hReBar = _GUICtrlReBar_Create($hgui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

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

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolBar_Create($hgui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
    Case 0
    _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
    Case 2
    _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

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

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

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

    ; create a combobox to put in the rebar
    $hCombo = _GUICtrlComboBox_Create($hgui, "", 0, 0, 120)

    _GUICtrlComboBox_BeginUpdate($hCombo)
    _GUICtrlComboBox_AddDir($hCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($hCombo)

    ; create a date time picker to put in the rebar
    $hDTP = _GUICtrlDTP_Create($hgui, 0, 0, 190)

    ; create a input box to put in the rebar
    $hInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

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

    ; default for add is append

    ; add band with control
    _GUICtrlReBar_AddBand($hReBar, $hCombo, 120, 200, "Dir *.exe")

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

    ; add band with date time picker
    _GUICtrlReBar_AddBand($hReBar, $hDTP, 120)

    ; add band with toolbar to begining of rebar
    _GUICtrlReBar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    ;add another control
    _GUICtrlReBar_AddBand($hReBar, GUICtrlGetHandle($hInput), 120, 200, "Name:")

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

    $btnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUISetState(@SW_SHOW)

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

    While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE, $btnExit
    Exit
    EndSwitch
    WEnd
    EndFunc ;==>_Main

    [/autoit]

    bernd670: Spoiler-Tags gesetzt!

    • Offizieller Beitrag

    Hallo,

    mit _GUICtrlToolbar_GetButtonState!

    Spoiler anzeigen
    [autoit]

    #include <GuiReBar.au3>
    #include <GuiToolBar.au3>
    #include <GuiComboBox.au3>
    #include <GuiDateTimePicker.au3>
    #include <WindowsConstants.au3>
    #include <Constants.au3>
    #include <GuiConstantsEx.au3>

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

    Opt("MustDeclareVars", 1)

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

    $Debug_RB = False

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

    Global $hReBar

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

    _Main()

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

    Func _Main()
    Local $hgui, $btnExit, $hToolbar, $hCombo, $hDTP, $hInput
    Local Enum $idNew = 1000, $idOpen, $idSave, $idHelp

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

    $hgui = GUICreate("Rebar", 400, 396, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX))

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

    ; create the rebar control
    $hReBar = _GUICtrlReBar_Create($hgui, BitOR($CCS_TOP, $WS_BORDER, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))

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

    ; create a toolbar to put in the rebar
    $hToolbar = _GUICtrlToolBar_Create($hgui, BitOR($TBSTYLE_FLAT, $CCS_NORESIZE, $CCS_NOPARENTALIGN))

    ; Add standard system bitmaps
    Switch _GUICtrlToolbar_GetBitmapFlags($hToolbar)
    Case 0
    _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_SMALL_COLOR)
    Case 2
    _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    EndSwitch

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

    ; Add buttons
    _GUICtrlToolbar_AddButton($hToolbar, $idNew, $STD_FILENEW)
    _GUICtrlToolbar_AddButton($hToolbar, $idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton($hToolbar, $idSave, $STD_FILESAVE)
    _GUICtrlToolbar_AddButtonSep($hToolbar)
    _GUICtrlToolbar_AddButton($hToolbar, $idHelp, $STD_HELP)

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

    ; create a combobox to put in the rebar
    $hCombo = _GUICtrlComboBox_Create($hgui, "", 0, 0, 120)

    _GUICtrlComboBox_BeginUpdate($hCombo)
    _GUICtrlComboBox_AddDir($hCombo, @WindowsDir & "\*.exe")
    _GUICtrlComboBox_EndUpdate($hCombo)

    ; create a date time picker to put in the rebar
    $hDTP = _GUICtrlDTP_Create($hgui, 0, 0, 190)

    ; create a input box to put in the rebar
    $hInput = GUICtrlCreateInput("Input control", 0, 0, 120, 20)

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

    ; default for add is append

    ; add band with control
    _GUICtrlReBar_AddBand($hReBar, $hCombo, 120, 200, "Dir *.exe")

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

    ; add band with date time picker
    _GUICtrlReBar_AddBand($hReBar, $hDTP, 120)

    ; add band with toolbar to begining of rebar
    _GUICtrlReBar_AddToolBarBand($hReBar, $hToolbar, "", 0)

    ;add another control
    _GUICtrlReBar_AddBand($hReBar, GUICtrlGetHandle($hInput), 120, 200, "Name:")

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

    $btnExit = GUICtrlCreateButton("Exit", 150, 360, 100, 25)
    GUISetState(@SW_SHOW)

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

    While 1
    If BitAND(_GUICtrlToolbar_GetButtonState($hToolbar, $idSave), $TBSTATE_PRESSED) = $TBSTATE_PRESSED Then
    MsgBox(0,"", "Save-Button")
    EndIf

    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE, $btnExit
    Exit
    EndSwitch
    WEnd
    EndFunc ;==>_Main

    [/autoit]
  • Das sollte man in WM_NOTIFY abfragen. Beispiel in in Hilfe bei ..._ButtonClick:

    Spoiler anzeigen
    [autoit]

    #include <GuiToolbar.au3>
    #include <GuiConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <Constants.au3>

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

    Opt('MustDeclareVars', 1)

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

    $Debug_TB = False ; Check ClassName being passed to functions, set to True and use a handle to another control to see it work

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

    Global $hToolbar, $iMemo
    Global $iItem ; Command identifier of the button associated with the notification.
    Global Enum $idNew = 1000, $idOpen, $idSave, $idHelp

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

    _Main()

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

    Func _Main()
    Local $hGUI, $aSize, $aStrings[4]

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

    ; Create GUI
    $hGUI = GUICreate("Toolbar", 600, 400)
    $hToolbar = _GUICtrlToolbar_Create ($hGUI)
    $aSize = _GUICtrlToolbar_GetMaxSize ($hToolbar)

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

    $iMemo = GUICtrlCreateEdit("", 2, $aSize[1] + 30, 596, 396 - ($aSize[1] + 30), $WS_VSCROLL)
    GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
    GUISetState()
    GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")

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

    ; Add standard system bitmaps
    _GUICtrlToolbar_AddBitmap ($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)

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

    ; Add strings
    $aStrings[0] = _GUICtrlToolbar_AddString ($hToolbar, "&New")
    $aStrings[1] = _GUICtrlToolbar_AddString ($hToolbar, "&Open")
    $aStrings[2] = _GUICtrlToolbar_AddString ($hToolbar, "&Save")
    $aStrings[3] = _GUICtrlToolbar_AddString ($hToolbar, "&Help")

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

    ; Add buttons
    _GUICtrlToolbar_AddButton ($hToolbar, $idNew, $STD_FILENEW, $aStrings[0])
    _GUICtrlToolbar_AddButton ($hToolbar, $idOpen, $STD_FILEOPEN, $aStrings[1])
    _GUICtrlToolbar_AddButton ($hToolbar, $idSave, $STD_FILESAVE, $aStrings[2])
    _GUICtrlToolbar_AddButtonSep ($hToolbar)
    _GUICtrlToolbar_AddButton ($hToolbar, $idHelp, $STD_HELP, $aStrings[3])

    ; Click Save button using accelerator
    _GUICtrlToolbar_ClickButton($hToolbar, $idSave, "left", True)

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

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

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

    EndFunc ;==>_Main

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

    ; Write message to memo
    Func MemoWrite($sMessage = "")
    GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
    EndFunc ;==>MemoWrite

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

    ; WM_NOTIFY event handler
    Func _WM_NOTIFY($hWndGUI, $MsgID, $wParam, $lParam)
    #forceref $hWndGUI, $MsgID, $wParam
    Local $tNMHDR, $event, $hwndFrom, $code, $i_idNew, $dwFlags, $lResult, $idFrom, $i_idOld
    Local $tNMTOOLBAR, $tNMTBHOTITEM
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hwndFrom = DllStructGetData($tNMHDR, "hWndFrom")
    $idFrom = DllStructGetData($tNMHDR, "IDFrom")
    $code = DllStructGetData($tNMHDR, "Code")
    Switch $hwndFrom
    Case $hToolbar
    Switch $code
    Case $NM_LDOWN
    ;----------------------------------------------------------------------------------------------
    MemoWrite("$NM_LDOWN: Clicked Item: " & $iItem & " at index: " & _GUICtrlToolbar_CommandToIndex ($hToolbar, $iItem))
    ;----------------------------------------------------------------------------------------------
    Case $TBN_HOTITEMCHANGE
    $tNMTBHOTITEM = DllStructCreate($tagNMTBHOTITEM, $lParam)
    $i_idOld = DllStructGetData($tNMTBHOTITEM, "idOld")
    $i_idNew = DllStructGetData($tNMTBHOTITEM, "idNew")
    $iItem = $i_idNew
    $dwFlags = DllStructGetData($tNMTBHOTITEM, "dwFlags")
    If BitAND($dwFlags, $HICF_LEAVING) = $HICF_LEAVING Then
    MemoWrite("$HICF_LEAVING: " & $i_idOld)
    Else
    Switch $i_idNew
    Case $idNew
    ;----------------------------------------------------------------------------------------------
    MemoWrite("$TBN_HOTITEMCHANGE: $idNew")
    ;----------------------------------------------------------------------------------------------
    Case $idOpen
    ;----------------------------------------------------------------------------------------------
    MemoWrite("$TBN_HOTITEMCHANGE: $idOpen")
    ;----------------------------------------------------------------------------------------------
    Case $idSave
    ;----------------------------------------------------------------------------------------------
    MemoWrite("$TBN_HOTITEMCHANGE: $idSave")
    ;----------------------------------------------------------------------------------------------
    Case $idHelp
    ;----------------------------------------------------------------------------------------------
    MemoWrite("$TBN_HOTITEMCHANGE: $idHelp")
    ;----------------------------------------------------------------------------------------------
    EndSwitch
    EndIf
    EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
    EndFunc ;==>_WM_NOTIFY

    [/autoit]