Sign in to follow this  
Followers 0
DORA

Toolbar problem ..... need help please

4 posts in this topic

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

Share this post


Link to post
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

[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

Share this post


Link to post
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
Sign in to follow this  
Followers 0