Home

Awesome

Class Toolbar

Class for AutoHotkey Toolbar custom controls

AHK version: 1.1.23.01

This class provides intuitive methods to work with Toolbar controls created via Gui, Add, Custom, ClassToolbarWindow32.

Note: It's recommended to call any method only after Gui, Show. Adding or modifying buttons of a toolbar in a Gui that is not yet visible might fail eventually.

Toolbar Methods:

Presets Methods:

Useful Toolbar Styles:

Styles can be applied to Gui command options, e.g.: Gui, Add, Custom, ClassToolbarWindow32 0x0800 0x0100


Add()

Add button(s) to the end the toolbar. The Buttons parameters sets target Label, text caption and icon index for each button. If not a valid label name, a function name can be used instead (parameters can be passed to the OnMessage method). To add a separator call this method without parameters. Prepend any non letter or digit symbol, such as "-" or "**" to the label to add a hidden button. Hidden buttons won't be visible when Gui is shown but will still be available in the customize window. E.g.: "-Label=New:1", "*Label:2".

Return

TRUE if successful, FALSE if there was a problem.

Parameters:

AutoSize()

Auto-sizes toolbar.

Return

TRUE if successful, FALSE if there was a problem.

Customize()

Displays the Customize Toolbar dialog box.

Return

TRUE if successful, FALSE if there was a problem.

Delete()

Delete one or all buttons.

Return

TRUE if successful, FALSE if there was a problem.

Parameters

Export()

Returns a text string with current buttons and order in Add and Insert methods compatible format (this includes button's styles but not states). Duplicate labels are ignored.

Return

A text string with current buttons information to be exported.

Parameters

Get()

Retrieves information from the toolbar.

Return

TRUE if successful, FALSE if there was a problem.

Parameters

GetButton()

Retrieves information from the toolbar buttons.

Return

TRUE if successful, FALSE if there was a problem.

Parameters

GetButtonPos()

Retrieves position and size of a specific button, relative to the toolbar control.

Return

TRUE if successful, FALSE if there was a problem.

Parameters

GetButtonState()

Retrieves the state of a button based on a querry.

Return

The TRUE if the StateQuerry is true, FALSE if it's not.

Parameters

GetCount()

Retrieves the total number of buttons.

Return

The total number of buttons in the toolbar.

GetHiddenButtons()

Retrieves which buttons are hidden when the toolbar size is smaller then the total size of the buttons it has. This method is most useful when the toolbar is a child window of a Rebar control, in order to show a menu when the chevron is pushed. It does not retrieve buttons hidden by gui size.

Return

An array with all buttons hidden by the Rebar band. Each key in the array has 4 properties: ID, Text, Label and Icon.

Insert()

Insert button(s) in specified postion. To insert a separator call this method without parameters.

Return

TRUE if successful, FALSE if there was a problem.

Parameters

LabelToIndex()

Converts a button label to its index in a toolbar.

Return

The 1-based index for the button or FALSE if Label is invalid.

Parameters

ModifyButton()

Sets button states.

Return

TRUE if successful, FALSE if there was a problem.

Parameters

ModifyButtonInfo()

Sets button parameters such as Icon and CommandID.

Return

TRUE if successful, FALSE if there was a problem.

Parameters

MoveButton()

Moves a toolbar button (change order).

Return

TRUE if successful, FALSE if there was a problem.

Parameters

OnMessage()

Run label associated with button's Command identifier. This method should be called from a function monitoring the WM_COMMAND message. Pass the wParam as the CommandID.

Return

TRUE if target label or function exists, or FALSE otherwise.

Parameters

OnNotify()

Handles toolbar notifications. This method should be called from a function monitoring the WM_NOTIFY message. Pass the lParam as the Param. The returned value should be used as return value for the monitoring function as well.

Return

The required return value for the function monitoring the the WM_NOTIFY message.

Parameters

Reset()

Restores all toolbar's buttons to default layout. Default layout is set by the buttons added. This can be changed calling the SetDefault method.

Return

TRUE if successful, FALSE if there was a problem.

SetButtonSize()

Sets the size of buttons on a toolbar. Affects current buttons.

Return

TRUE if successful, FALSE if there was a problem.

Parameters

SetDefault()

Sets the internal default layout to be used when customizing or when the Reset method is called.

Return

Always TRUE.

Parameters