SetToolbar

Description

Specifies the alignment, visibility, and title for the specified toolbar.

Applies to

MDI frame and sheet windows

Syntax

window.SetToolbar ( toolbarindex, visible {, alignment {, floatingtitle } } )

Argument

Description

window

The MDI frame or sheet to which the toolbar belongs.

toolbarindex

An integer whose value is the index of the toolbar whose settings you want to change.

visible

A boolean value specifying whether to make the toolbar visible. Values are:

  • TRUE – Make the toolbar visible

  • FALSE – Hide the toolbar

alignment (optional)

A value of the ToolbarAlignment enumerated datatype specifying the alignment for the toolbar. Values are:

  • AlignAtTop! – Dock the toolbar at the top of the frame.

  • AlignAtLeft! – Dock the toolbar on the left side of the frame.

  • AlignAtRight! – Dock the toolbar on the right side of the frame.

  • AlignAtBottom! – Dock the toolbar at the bottom of the frame.

  • Floating! – Float the toolbar. The floating toolbar has its own frame and miniature title bar

floatingtitle (optional)

A string whose value is the title for the toolbar when its alignment is Floating!.

Returns

Integer. Returns 1 if it succeeds. SetToolbar returns -1 if there is no toolbar for the index you specify or if an error occurs. If any argument’s value is null, returns null.

Usage

When you use SetToolbar to change the toolbar alignment from a docked position to Floating!, PowerBuilder uses the last known position information unless you also call SetToolbarPos to adjust the position.

The toolbars are not redrawn until the script ends, so setting the alignment with SetToolbar and the position with SetToolbarPos looks like a single change to the user.

Examples

Example 1

This example allows the user to choose an alignment in a ListBox lb_position. The selected string is converted to a ToolbarAlignment enumerated value, which is used to change the alignment of toolbar index 1:

toolbaralignment tba_align


CHOOSE CASE lb_position.SelectedItem()


CASE "Top"

		tba_align = AlignAtTop!

CASE "Left"

		tba_align = AlignAtLeft!

CASE "Right"

		tba_align = AlignAtRight!

CASE "Bottom"

		tba_align = AlignAtBottom!

CASE "Floating"

		tba_align = Floating!

END CHOOSE


w_frame.SetToolbar(1, TRUE, tba_align)

Example 2

In this example, the user clicks a radio button to choose an alignment. The radio button’s Clicked event sets an instance variable of type ToolbarAlignment. Here the radio buttons are packaged as a custom visual user object. I_toolbaralign is an instance variable of the user object. This is the script for the Top radio button:

Parent.i_toolbaralign = AlignAtTop!

Example 3

This script changes the toolbar alignment:

w_frame.SetToolbar(1, TRUE, &

		uo_toolbarpos.i_toolbaralign )

See also