Toolbar

Toolbar control

Summary
Toolbar control
Add toolbar to the GUI
Set button information
Set all butons at once using textual definition
Get button information
Get count of buttons on the toolbar
Delete button from the toolbar
Get button rectangle
Get number of toolbar rows

Add

Toolbar_Add(hGui,  
hIL = "1S 7,8,9,|,2,3,|,4,5,10",
style = "WRAPABLE FLAT LIST")

Add toolbar to the GUI

Parameters

hGuiHWND of the GUI
hILIf number, handle of the image list that contains button images.  If string (default), default image list will be used, see details bellow
styleStyles to apply to the toolbar control, see list of styles bellow.

Default image list

If hIL isn’t number, you must specify string in strict format.  The syntax is *CS iconlist” where C is catalog number (1-4) and S is the icon size - S (small, 16px) or L (large, 24px).  Iconlist is the list of icons you want to use from desired catalog (each catalog has different number of images - from 5 to 15) By default, hIL is set as ”1S 7,8,9,|,2,3,|,4,5,10” so that first catalog and large images are used, and icons as specified.  You can set “|” instead of icon number to insert separator button at particular position

Control Styles

WRAPABLECreates a toolbar that can have multiple lines of buttons.  Toolbar buttons can “wrap” to the next line when the toolbar becomes too narrow to include all buttons on the same line.  When the toolbar is wrapped, the break will occur on either the rightmost separator or the rightmost button if there are no separators on the bar.  This style must be set to display a vertical toolbar control when the toolbar is part of a vertical rebar control.  This style cannot be combined with CCS_VERT.
FLATCreates a flat toolbar.  In a flat toolbar, both the toolbar and the buttons are transparent and hot-tracking is enabled.  Button text appears under button bitmaps.  To prevent repainting problems, this style should be set before the toolbar control becomes visible.
LISTCreates a flat toolbar with button text to the right of the bitmap.  Otherwise, this style is identical to TBSTYLE_FLAT.  To prevent repainting problems, this style should be set before the toolbar control becomes visible.

Returns

Handle of the toolbar

SetButtonInfo

Toolbar_SetButtonInfo(hToolbar,  
id,  
text = "",
state = "")

Set button information

Parameters

hToolbarHWND of the toolbar
idButton identification (currently equal to buttons position)
textText to set for the button.  If “” text will not be changed.  If “-” text wil be removed (the same as omiting both text and state parameters)
stateList of button states to set, separated by white space.  See bellow.

Button states

CHECKED, ENABLED, HIDDEN, GRAYED, PRESSED, CLICKED

Returns

Nonzero if successful, or zero otherwise.

SetButtons

Toolbar_SetButtons(hToolbar,  
info = "")

Set all butons at once using textual definition

Parameters

hToolbarHWND of the toolbar
infoTextual definition of buttons info.  For each button there should be line containg text|state list where both text and state list are optional.  You can also use “-” to skip button (the same as empty line).  If you omit this parameter text and state for each button will be cleared

GetButtonInfo

Toolbar_GetButtonInfo(hToolbar,  
id,  
info = "text")

Get button information

Parameters

hToolbarHWND of the toolbar
idID of the button (currently the same as position)
infoWhat kind of info to return - text (default) or state

GetButtonCount

Toolbar_GetButtonCount(hToolbar)

Get count of buttons on the toolbar

Parameters

hToolbarHWND of the toolbar

Returns

Count

DeleteButton

Toolbar_DeleteButton(hToolbar,  
idx = 1)

Delete button from the toolbar

Parameters

hToolbarHWND of the toolbar
idx1-based position of the button

Returns

TRUE if successful, or FALSE otherwise.

GetRect

Toolbar_GetRect(hToolbar,
id)

Get button rectangle

Parameters

hToolbarHWND of the toolbar
idButton id

Returns

String with 4 rect values, separated by space

GetRows

Toolbar_GetRows(hToolbar)

Get number of toolbar rows

Parameters

hToolbarHWND of the toolbar

Returns

Count

Example

Gui, +LastFound
hwnd := WinExist()
Gui, Show ,w280 h200 ;set gui width & height (mandatory)
hToolbar := Toolbar_Add(hwnd)

About

Toolbar_Add(hGui,  
hIL = "1S 7,8,9,|,2,3,|,4,5,10",
style = "WRAPABLE FLAT LIST")
Add toolbar to the GUI
Toolbar_SetButtonInfo(hToolbar,  
id,  
text = "",
state = "")
Set button information
Toolbar_SetButtons(hToolbar,  
info = "")
Set all butons at once using textual definition
Toolbar_GetButtonInfo(hToolbar,  
id,  
info = "text")
Get button information
Toolbar_GetButtonCount(hToolbar)
Get count of buttons on the toolbar
Toolbar_DeleteButton(hToolbar,  
idx = 1)
Delete button from the toolbar
Toolbar_GetRect(hToolbar,
id)
Get button rectangle
Toolbar_GetRows(hToolbar)
Get number of toolbar rows