SetToolbar PowerScript function
Description
Specifies the alignment, visibility, and title for the specified
toolbar.
Controls
MDI frame and sheet windows
Syntax
1 |
<span>window</span>.<span>SetToolbar</span> ( <span>toolbarindex</span>, <span>visible</span> {, <span>alignment</span> {, <span>floatingtitle</span> } } ) |
Argument |
Description |
---|---|
window |
The MDI frame or sheet to which the toolbar |
toolbarindex |
An integer whose value is the index of |
visible |
A boolean value specifying whether to
|
alignment |
A value of the ToolbarAlignment enumerated
|
floatingtitle |
A string whose value is the title for |
Return Values
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
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:
1 |
toolbaralignment tba_align |
1 |
1 |
CHOOSE CASE lb_position.SelectedItem() |
1 |
1 |
CASE "Top" |
1 |
tba_align = AlignAtTop! |
1 |
CASE "Left" |
1 |
tba_align = AlignAtLeft! |
1 |
CASE "Right" |
1 |
tba_align = AlignAtRight! |
1 |
CASE "Bottom" |
1 |
tba_align = AlignAtBottom! |
1 |
CASE "Floating" |
1 |
tba_align = Floating! |
1 |
END CHOOSE |
1 |
1 |
w_frame.<span>SetToolbar</span>(1, TRUE, tba_align) |
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:
1 |
Parent.i_toolbaralign = AlignAtTop! |
This script changes the toolbar alignment:
1 |
w_frame.<span>SetToolbar</span>(1, TRUE, & |
1 |
uo_toolbarpos.i_toolbaralign ) |