Jump to content

Toolbar problem ..... need help please


DORA
 Share

Recommended Posts

this my code how to know if a button in toolbar was pressed :D

#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 :D

Link to comment
Share on other sites

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
Link to comment
Share on other sites

it works for me :D

but how can i teel which button was pressed and do an action like msgbox

can we use case

what 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 by DORA
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...