ToolBar Ocx

Purpose

Creates an Ocx ToolBar control in the current active form, window, or dialog.

Syntax

Ocx ToolBar name = text$ [, id], x, y, b, h [, style%]

text$:control text
id%:control identifier
x, y, b, h:iexp
style%:the control styles

Description

A Toolbar control contains a collection of Button objects used to create a toolbar that is associated with an application.

Typically, a toolbar contains buttons that correspond to items in an application's menu, providing a graphic interface for the user to access an application's most frequently used functions and commands.

The Toolbar control allows you to create toolbars by adding Button objects to a Buttons collection. Each Button object can have optional text or an image, or both, supplied by an associated ImageList control. You can display an image on a button with the Image property, or display text with the Caption property, or both, for each Button object. At run time, you can add or remove buttons from the Buttons collection using the Add and Remove methods (See Remarks).

To program the Toolbar, add code to the ButtonClick event to respond to the selected button. You can also determine the behavior and appearance of each Button object using the Style property. For example, if four buttons are assigned the 'Button Group' style (2), only one button can be pressed at any time and at least one button is always pressed.

You can create space for other controls on the toolbar by assigning a Button object the 'Place Holder' style (4), then positioning a control over the placeholder. For example, to place a drop-down combo box on a toolbar, add a Button object with the 'Place Holder' style and size it as wide as a ComboBox control. Then place a ComboBox control on the placeholder with the OcxOcx command.

Usability is further enhanced by programming ToolTipText descriptions of each Button object. To display ToolTips, simply assign a value to the ToolTipText property.

The ToolBar Ocx control has the following properties, methods, and events.

Properties

Appearance | BorderStyle | Button | Buttons | Count | Enabled | Font | FontBold | FontItalic | FontStrikethru | FontUnderline | FontName | FontSize | Height | HelpContextID | hWnd | ImageList | Left | MouseCursor | MouseIcon | MousePointer | Name | Tag | ToolTiptext | Top | Visible | WhatsThisHelpID | Width

Methods

Add | AddItem | Clear | Item | Refresh | Remove | SetFont | TextHeight | TextWidth

Events

Click | ButtonClick | ButtonDblClick | DblClick | MouseDown | MouseUp | MouseMove

Example

Ocx ToolBar tb

tb.Buttons.Add , , "Save"

tb.Add , , "Load"

Do : Sleep : Until Me Is Nothing

 

Sub tb_ButtonClick(Btn As Button)

Select Btn.Index

Case 1 : Message "Save selected"

Case 2 : Message "Load selected"

EndSelect

EndSub

Remarks

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

The ToolBar Ocx control implicitly changes the origin of the scaling mode. The origin is moved with SetViewportOrgEx API. ScaleHeight is decremented with the height of the toolbar. Mouse client coordinates are relative to the new origin.

See Also

Form, Command, Option, CheckBox, RichEdit, ImageList, TreeView, ListView, Timer, Slider, Scroll, Image, Label, ProgressBar, TextBox, StatusBar, ListBox, ComboBox, Frame, CommDlg, MonthView, TabStrip, TrayIcon, Animation, UpDown

Ocx, OcxOcx, Buttons, Button

{Created by Sjouke Hamstra; Last updated: 25/10/2014 by James Gaite}