Sizing the client area
PowerBuilder sizes the client area in a standard MDI frame
window automatically and displays open sheets unclipped within the
client area. It also sizes the client area automatically if you
have defined a toolbar based on menu items, as described in the
preceding section.
However, in a custom MDI frame window—where the client
area contains controls in addition to open sheets—PowerBuilder
does not size the client area; you must size it. If you do not size
the client area, the sheets open but may not be visible and are
clipped if they exceed the size of the client area.
If you plan to use an MDI toolbar with a custom MDI frame,
make sure the controls you place in the frame’s client
area are far enough away from the client area’s borders
so that the toolbar does not obscure them when displayed.
Scrollbars display when a sheet is clipped If you selected HScrollBar and VScrollBar when defining the
window, the scrollbars display when a sheet is clipped. This means
not all the information in the sheet is displayed. The user can
then scroll to display the information.
When you create a custom MDI frame window, PowerBuilder creates
a control named MDI_1 to identify
the client area of the frame. If you have enabled AutoScript, MDI_1 displays
in the list of objects in the AutoScript pop-up window when you
create a script for the frame.
To size or resize the client area when the frame
is opened or resized:
-
Write a script for the frame’s
Open or Resize event that:- Determines the size
of the frame - Sizes the client area (MDI_1)
appropriately
- Determines the size
For example, the following script sizes the client area for
the frame w_genapp_frame.
The frame has a series of buttons running across the frame just
below the menu, and MicroHelp at the bottom:
1 |
int li_width, li_height<br /> <br />//Get the width and height of the frame's workspace.<br />//<br />//Note that if the frame displays any MDI toolbars,<br />//those toolbars take away from the size of the<br />//workspace as returned by the WorkSpaceWidth and<br />//WorkSpaceHeight functions. Later, you see how to<br />//to adjust for this.<br />//<br />li_width = w_genapp_frame.WorkSpaceWidth()<br /> <br />li_height = w_genapp_frame.WorkSpaceHeight()<br /> <br />//Next, determine the desired height of the client<br />//area by doing the following:<br />//<br />// 1) Subtract from the WorkSpaceHeight value: the<br />// height of your control and the Y coordinate of<br />// the control (which is the distance between the<br />// top of the frame's workspace -- as if no<br />// toolbars were there -- and the top of your<br />// control).<br />//<br />// 2) Then subtract: the height of the frame's<br />// MicroHelp bar (if present)<br />//<br />// 3) Then add back: the height of any toolbars that<br />// are displayed (to adjust for the fact that the<br />// original WorkSpaceHeight value we started with<br />// is off by this amount). The total toolbar<br />// height is equal to the Y coordinate returned <br />// by the WorkspaceY function.<br /> <br />li_height = li_height - (cb_print.y + cb_print.height)<br /> <br />li_height = li_height - MDI_1.MicroHelpHeight<br /> <br />li_height = li_height + WorkspaceY()<br /> <br />//Now, move the client area to begin just below your<br />//control in the workspace.<br /> <br />mdi_1.Move (WorkspaceX (), cb_print.y + & <br /> cb_print.height)<br /> <br />//Finally, resize the client area based on the width<br />//and height you calculated earlier.<br /> <br />mdi_1.Resize (li_width, li_height) |
About MicroHelpHeight MicroHelpHeight is a property of MDI_1 that
PowerBuilder sets when you select a window type for your MDI window.
If you select MDI Frame, there is no MicroHelp and MicroHelpHeight
is 0; if you select MDI Frame with MicroHelp, MicroHelpHeight is
the height of the MicroHelp.