Sign in to follow this  
Followers 0
TheBobynator

Need help with toolbar

3 posts in this topic

Can someone help me look:

#include <GUIConstantsEx.au3>
#Include <GuiToolBar.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>



$Fenster = GUICreate("TEST TEST TEST", 460, 490)
GUISetState(@SW_SHOW)
;Toolbar--------------------------------------------------------------
$hToolbar= _GUICtrlToolbar_Create($Fenster)
_GUICtrlToolbar_AddBitmap ($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
$1=_GUICtrlToolbar_AddButton ($hToolbar, 1000, $STD_FILENEW)
$2=_GUICtrlToolbar_AddButton ($hToolbar, 1000, $STD_FILEOPEN)
$3=_GUICtrlToolbar_AddButton ($hToolbar, 1000, $STD_FILESAVE)
$4=_GUICtrlToolbar_AddButtonSep ($hToolbar)
$5=_GUICtrlToolbar_AddButton ($hToolbar, 1000, $STD_HELP)


While 1
    $msg = GUIGetMsg(1)
        Select
            Case $msg[0] = $GUI_EVENT_CLOSE 
                    Exit
                Case $msg[0] = $1
                    MsgBox(0,"TEST","This is a Test")
        EndSelect
WEnd

If I start this every second opens the msgbox but I want if I click the button the msgbox will open.

So can someone help me

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Can someone help me look:

#include <GUIConstantsEx.au3>
#Include <GuiToolBar.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>



$Fenster = GUICreate("TEST TEST TEST", 460, 490)
GUISetState(@SW_SHOW)
;Toolbar--------------------------------------------------------------
$hToolbar= _GUICtrlToolbar_Create($Fenster)
_GUICtrlToolbar_AddBitmap ($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
$1=_GUICtrlToolbar_AddButton ($hToolbar, 1000, $STD_FILENEW)
$2=_GUICtrlToolbar_AddButton ($hToolbar, 1000, $STD_FILEOPEN)
$3=_GUICtrlToolbar_AddButton ($hToolbar, 1000, $STD_FILESAVE)
$4=_GUICtrlToolbar_AddButtonSep ($hToolbar)
$5=_GUICtrlToolbar_AddButton ($hToolbar, 1000, $STD_HELP)


While 1
    $msg = GUIGetMsg(1)
        Select
            Case $msg[0] = $GUI_EVENT_CLOSE 
                    Exit
                Case $msg[0] = $1
                    MsgBox(0,"TEST","This is a Test")
        EndSelect
WEnd

If I start this every second opens the msgbox but I want if I click the button the msgbox will open.

So can someone help me

Toolbars don't work like that. Every control in the toolbar needs its own ID; only one should have the ID 1000. The return from _GUICtrlToolbar_AddButton is a boolean value not an id, so you are testing if $msg[0] is true.

Have a look at the example in the help for _GUICtrlToolbar_Create which will show you how to use a toolbar.

Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

thx

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