DORA Posted September 27, 2009 Posted September 27, 2009 this my code how to know if a button in toolbar was pressed #include <Constants.au3> #include <GUIConstantsEx.au3> #include <GuiToolbar.au3> #include <ToolbarConstants.au3> #include <WindowsConstants.au3> Local $idNew, $idNew1, $idNew2, $idNew3 $Form1 = GUICreate("Form1", 605, 267, 192, 124) $ToolBar1 = _GUICtrlToolbar_Create($Form1, 0) $aSize = _GUICtrlToolbar_GetMaxSize($ToolBar1) _GUICtrlToolbar_AddBitmap($ToolBar1, 1, -1, $IDB_STD_LARGE_COLOR) _GUICtrlToolbar_AddButton($ToolBar1, $idNew, $STD_FILENEW) _GUICtrlToolbar_AddButton($ToolBar1, $idNew1, $STD_FILEOPEN) _GUICtrlToolbar_AddButton($ToolBar1, $idNew2, $STD_FILESAVE) _GUICtrlToolbar_AddButtonSep($ToolBar1,5) _GUICtrlToolbar_AddButton($ToolBar1, $idNew3, $STD_HELP) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd thank you all
dantay9 Posted September 27, 2009 Posted September 27, 2009 I think this is the best way: #include <Constants.au3> #include <GUIConstantsEx.au3> #include <GuiToolbar.au3> #include <ToolbarConstants.au3> #include <WindowsConstants.au3> Local $idNew, $idNew1, $idNew2, $idNew3 $Form1 = GUICreate("Form1", 605, 267, 192, 124) $ToolBar1 = _GUICtrlToolbar_Create($Form1, 0) $aSize = _GUICtrlToolbar_GetMaxSize($ToolBar1) _GUICtrlToolbar_AddBitmap($ToolBar1, 1, -1, $IDB_STD_LARGE_COLOR) _GUICtrlToolbar_AddButton($ToolBar1, $idNew, $STD_FILENEW) _GUICtrlToolbar_AddButton($ToolBar1, $idNew1, $STD_FILEOPEN) _GUICtrlToolbar_AddButton($ToolBar1, $idNew2, $STD_FILESAVE) _GUICtrlToolbar_AddButtonSep($ToolBar1, 5) _GUICtrlToolbar_AddButton($ToolBar1, $idNew3, $STD_HELP) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch If _GUICtrlToolbar_IsButtonPressed($ToolBar1, $idNew) Then ;sleep while the button is pressed While _GUICtrlToolbar_IsButtonPressed($ToolBar1, $idNew) Sleep(100) WEnd ConsoleWrite("TEST" & @CRLF) EndIf WEnd
DORA Posted September 27, 2009 Author Posted September 27, 2009 (edited) it works for me but how can i teel which button was pressed and do an action like msgboxcan we use casewhat is wrong here ?#include <Constants.au3> #include <GUIConstantsEx.au3> #include <GuiToolbar.au3> #include <ToolbarConstants.au3> #include <WindowsConstants.au3> Local $idNew, $idNew1, $idNew2, $idNew3 $Form1 = GUICreate("Form1", 605, 267, 192, 124) $ToolBar1 = _GUICtrlToolbar_Create($Form1, 0) $aSize = _GUICtrlToolbar_GetMaxSize($ToolBar1) _GUICtrlToolbar_AddBitmap($ToolBar1, 1, -1, $IDB_STD_LARGE_COLOR) _GUICtrlToolbar_AddButton($ToolBar1, $idNew, $STD_FILENEW) _GUICtrlToolbar_AddButton($ToolBar1, $idNew1, $STD_FILEOPEN) _GUICtrlToolbar_AddButton($ToolBar1, $idNew2, $STD_FILESAVE) _GUICtrlToolbar_AddButtonSep($ToolBar1, 5) _GUICtrlToolbar_AddButton($ToolBar1, $idNew3, $STD_HELP) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case _GUICtrlToolbar_IsButtonPressed($ToolBar1, $idNew) ;sleep while the button is pressed While _GUICtrlToolbar_IsButtonPressed($ToolBar1, $idNew) Sleep(100) WEnd ConsoleWrite("TEST" & @CRLF) EndSwitch WEnd Edited September 27, 2009 by DORA
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now