Syntax 2: For floating toolbars
Description
Sets the position and size of a floating toolbar.
Applies to
MDI frame and sheet windows
Syntax
1 |
window.SetToolbarPos ( toolbarindex, x, y, width, height ) |
Argument |
Description |
---|---|
window |
The MDI frame or sheet to which the toolbar |
toolbarindex |
An integer whose value is the index of the toolbar whose |
x |
An integer whose value is the x coordinate of the |
y |
An integer whose value is the y coordinate of the |
width |
An integer whose value is the width of the floating |
height |
An integer whose value is the height of the floating |
Return value
Integer.
Returns 1 if it succeeds. SetToolbarPos returns -1 if there is no
toolbar for the index you specify or if an error occurs. If any
argument’s value is null, SetToolbarPos returns null.
Usage
If the toolbar’s alignment is a docked position, instead of
floating, then values you specify with Syntax 2 of SetToolbarPos take
effect when you change the alignment to floating in a script with
SetToolbar.
If the user drags the toolbar to a floating position, the new
position values replace values set with SetToolbarPos.
The floating toolbar is never too large or too small for the
buttons. If you specify width and height values that are too small to
accommodate the buttons, the width and height are adjusted to make room
for the buttons. If both width and height are larger than needed, the
height is reduced.
If you specify x and y coordinates that are outside the frame, the
toolbar becomes inaccessible to the user.
Examples
This example displays toolbar 1 near the upper-left corner of the
frame. An arbitrary width and height lets PowerBuilder size the toolbar
as needed:
1 2 |
w_frame.SetToolbarPos(1, 10, 10, 400, 1) w_frame.SetToolbar(1, TRUE, Floating!) |
This example displays toolbar 2 close to the lower-right corner of
the frame. GetToolbarPos gets the current width and height of the
toolbar so that the toolbar stays the same size:
1 2 3 4 5 6 7 8 9 |
integer ix, iy, iw, ih w_frame.GetToolbarPos(2, ix, iy, iw, ih) w_frame.SetToolbarPos(2, & w_frame.WorkspaceWidth()-400, & w_frame.WorkspaceHeight()-400, & iw, ih) w_frame.SetToolbar(2, TRUE, Floating!) |
This example positions floating toolbar 2 just inside the
lower-right corner of the MDI frame. GetToolbarPos gets the current
width and height of the toolbar. These values and the height of the
MicroHelp are used to calculate the x and y coordinates for the floating
toolbar:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
integer ix, iy, iw, ih // Find out toolbar size w_frame.GetToolbarPos(2, ix, iy, iw, ih) // Set the position, taking the size into account w_frame.SetToolbarPos(2, & w_frame.WorkspaceWidth( ) - iw, & w_frame.WorkspaceHeight( ) & - ih - w_frame.MDI_1.MicroHelpHeight, & iw, ih) // Set the alignment to floating w_frame.SetToolbar(2, TRUE, Floating!) |
See also