Jump to content
Sign in to follow this  
dzony91

Simple toolbar gui

Recommended Posts

dzony91

Hi, i want to make gui with toolbar like this, with custom icons...

post-28075-1207264106_thumb.jpg

Share this post


Link to post
Share on other sites
Swift

You could please do just a small search? This has been asked so many times, and very recent.

Share this post


Link to post
Share on other sites
Zedna

Latest release or Beta look in the help for:

_GUICtrlReBar_Create

_GUICtrlToolBar_Create

I looked at these functions and also at _GUICtrlToolbar_AddButton()

but in helpfile are only examples using standard New/Open/Save buttons.

I would like to see also some simple example for custom buttons/images on the toolbar if somebody has created such one already.

Share this post


Link to post
Share on other sites
dzony91

Great example, but look this, i have this example and listle is buges :S

toolbar and menu is litlle discrete :S

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=sdf.ico
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
;AutoIt3 v3.2.10.0 or higher
#include <GuiConstantsEx.au3>
#include <GuiToolbar.au3>
#include <GuiToolTip.au3>
#Include <GuiRebar.au3>
#Include <GuiImageList.au3>

Opt('MustDeclareVars', 1)

Global $iItem ; Command identifier of the button associated with the notification.
Global $hGUI, $hToolbar, $hToolTip, $hReBar, $iMemo, $aStrings[5], $i = 0
Global Enum $id1 = 1000, $id2, $id3, $id4, $id5 ; ID's for each ToolBar button

    Local $hToolBarImageListNorm, $hToolBarImageListDisabled, $hToolBarImageListHot, $aSize
    $hGUI = GUICreate("Toolbar", 400, 300)

    $hReBar = _GUICtrlReBar_Create($hGUI, BitOR($RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS))
    $hToolbar = _GUICtrlToolbar_Create($hGUI)

    $aSize = _GUICtrlToolbar_GetMaxSize($hToolbar)
    ; Create ToolTip
    $hToolTip = _GUIToolTip_Create($hToolbar, $TTS_ALWAYSTIP)
    _GUICtrlToolbar_SetToolTips($hToolbar, $hToolTip)

    ; Add Icons from system DLL shell32.dll to ImageList
    $hToolBarImageListNorm = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hToolBarImageListNorm, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hToolBarImageListNorm, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hToolBarImageListNorm, @SystemDir & "\shell32.dll", 165)
    _GUIImageList_AddIcon($hToolBarImageListNorm, @SystemDir & "\shell32.dll", 168)
    _GUIImageList_AddIcon($hToolBarImageListNorm, @SystemDir & "\shell32.dll", 137)
    _GUIImageList_AddIcon($hToolBarImageListNorm, @SystemDir & "\shell32.dll", 146)

    ; add AutoIt icon from exe internal resources or icon added at compile time by compiler directives
    _GUIImageList_AddIcon($hToolBarImageListNorm, @AutoItExe, 0) ; AutoIt icon if run in Scite or compiled
    _GUICtrlToolbar_SetImageList($hToolbar, $hToolBarImageListNorm)
    
    ; Add buttons

    _GUICtrlToolbar_AddButton($hToolbar, $id1, 0, $aStrings[0]) ; Index 0
    _GUICtrlToolbar_AddButton($hToolbar, $id2, 1, $aStrings[1]) ; Index 1
    _GUICtrlToolbar_AddButton($hToolbar, $id3, 2, $aStrings[2]) ; Index 2
    _GUICtrlToolbar_AddButtonSep($hToolbar) ; Index 3 - separators have index values
    _GUICtrlToolbar_AddButton($hToolbar, $id4, 3, $aStrings[3]) ; Index 4
    _GUICtrlToolbar_AddButtonSep($hToolbar) ; Index 5 - separators have index values
    _GUICtrlToolbar_AddButton($hToolbar, $id5, 6, $aStrings[4]) ; Index 6

    _GUICtrlReBar_AddToolBarBand($hReBar, $hToolbar, "", 0)
GuiCtrlCreateMenu ("Help")
    ; Remove
    GUISetState()
    GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")
    ; /Remove
    
    ; Loop until user exits
    Do
        Sleep(10)
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

; WM_NOTIFY event handler for Toolbar button press events and tooltips
Func _WM_NOTIFY($hWndGUI, $MsgID, $wParam, $lParam)
    #forceref $hWndGUI, $MsgID, $wParam
    Local $hwndFrom, $code, $index
    Local $tNMTOOLBAR, $tInfo, $iID
    
    $tNMTOOLBAR = DllStructCreate($tagNMTOOLBAR, $lParam)
    $tInfo = DllStructCreate($tagNMTTDISPINFO, $lParam)
    $hwndFrom = DllStructGetData($tNMTOOLBAR, "hWndFrom")
    $code = DllStructGetData($tNMTOOLBAR, "Code")
    $iItem = DllStructGetData($tNMTOOLBAR, "iItem")

    Switch $hwndFrom
        Case $hToolbar
            Switch $code
                Case $TBN_BEGINDRAG
                    $index = _GUICtrlToolbar_CommandToIndex($hToolbar, $iItem)
                    ; Remove
                    ;------------------------------------------------------------------
                    ;------------------------------------------------------------------
                    ; /Remove
                    Switch _GUICtrlToolbar_IsButtonEnabled($hToolbar, $iItem)
                        Case True
                            Switch $index
                                Case 0
                                    Beep(1000, 5)
                                Case 1
                                    Beep(1500, 5)
                                    Exit
                                Case 2
                                    Beep(2000, 5)
                                    ; Disable / Enable Button 4 - Button 3 Is Checked when button 4 is disabled
                                    If _GUICtrlToolbar_IsButtonEnabled($hToolbar, $id4) Then
                                        _GUICtrlToolbar_EnableButton($hToolbar, $id4, False)
                                        _GUICtrlToolbar_CheckButton($hToolbar, $id3, True)
                                    Else
                                        _GUICtrlToolbar_EnableButton($hToolbar, $id4, True)
                                        _GUICtrlToolbar_CheckButton($hToolbar, $id3, False)
                                    EndIf
                                Case 4
                                    Beep(2500, 5)
                                Case 6
                                    Beep(3000, 5)
                                    SoundPlay(@WindowsDir & "\media\tada.wav", 0)
                            EndSwitch
                    EndSwitch
            EndSwitch
        Case $hToolTip
            Switch $code ; Toolbar Button Tooltips
                Case $TTN_GETDISPINFO
                    $iID = DllStructGetData($tInfo, "IDFrom")
                    Switch $iID
                        Case $id1
                            DllStructSetData($tInfo, "aText", "Open")
                        Case $id2
                            DllStructSetData($tInfo, "aText", "Exit")
                        Case $id3
                            DllStructSetData($tInfo, "aText", "Options")
                        Case $id4
                            DllStructSetData($tInfo, "aText", "Tunes")
                        Case $id5
                            DllStructSetData($tInfo, "aText", "AutoIt")
                    EndSwitch
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>_WM_NOTIFY
Edited by dzony91

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.