Buttons, Button Objects

Purpose

A Buttons object is a collection of Button objects. A Button object represents an individual button in the Buttons collection of a Toolbar control.

Syntax

ToolBar.Buttons

ToolBar.Buttons(index)

ToolBar.Button(index)

index:Variant

Description

The ToolBar.Buttons property returns a reference to the Buttons object, a collection of Button objects.

ToolBar.Buttons(index) or Button(index) returns a reference to the Button with the given index (integer or string).

For each Button object, you can add text or a bitmap image, or both, from an ImageList control, and set properties to change its state and style. You can manipulate Button objects using standard collection methods (for example, the Add and Remove methods). Each element in the collection can be accessed by its index, the value of the Index property, or by a unique key, the value of the Key property.

The Buttons properties and methods:

Add | Clear | Count | Item | Remove

The Button properties and methods:

Caption | Checked | Enabled | Height | Hidden | Image | Indeterminate | Index | Key | Left | Pressed | Style | Tag | ToolTipText | Top | Value | Width

Example

Ocx ToolBar tlb

tlb.Add , "open" , "Open"

tlb.Add , "save" , "Save"

Debug.Show

Trace tlb.Button(1).Caption

Trace tlb.Buttons(2).Key

Trace tlb("open").Index

Do : Sleep : Until Me Is Nothing

Known Issues

  1. The Toolbar and Buttons methods Clear and Remove don't work correctly and will eventually crash GFA-BASIC 32.

  2. Although the text of the Button caption can be retrieved using Button.Caption, the ability to set the caption after it has been created has never been implemented in GB32. There is no known workaround to this.

See Also

ToolBar

{Created by Sjouke Hamstra; Last updated: 09/05/2020 by James Gaite}