Window behavior – PB Docs 70

Window behavior

The PowerBuilder basic window types provide similar functionality
on all platforms, but there are a few special considerations. The
topics in this section include areas where behavior is the same
as well as where it differs. You also need to consider where windows
are displayed when users have different screen sizes and resolutions.

MDI applications, child windows, and focus

MDI applications

Multiple document interface (MDI) applications are popular
on Windows. A frame window with a menu bar at the top encloses all
the other windows of your application. This model is also common
for Motif applications.

Child windows on UNIX

On UNIX systems using Motif, a child window can sometimes
be overlaid by its parent window. This occurs when the child window
is of type main rather than type child, because a main window in
Motif is a top-level widget that can be raised or lowered independently
of its parent. This is different from the behavior on Windows but
is consistent with the Motif style.

Tabbing and focus for controls

In a window, a control that has focus is ready to receive
keyboard input. The user changes focus by clicking a control or
by tabbing. On both Windows and UNIX systems, any control can have

Window placement andscreen size

When you design your application, window placement is an important
design consideration. In the Window painter, you specify where a
window will appear on the screen when it opens (unless you are opening
it as a sheet in an MDI frame). The size and position of the window,
as well as objects within the window (such as DataWindows), are
specified in PowerBuilder units (PBUs).

Because PBUs are defined in terms of logical inches, the position
of the window gets adjusted if you run your application on another
system with a different screen configuration. The size of a logical
inch is defined by your operating system as a specific number of
pixels. The number is dependent on the display device. For example,
on a Windows 95 system using Small Fonts on a standard VGA display,
the number of pixels per logical inch is 96.

Unlike window and user objects, DataWindows and reports can
be created in units of one thousandth of an inch or one thousandth
of a centimeter, as well as in PBUs. If you plan to move your PBL
among platforms, the size of DataWindow and report objects will
be more consistent across platforms if you use inches or centimeters
as the unit of measurement.

Pixel size–variable or fixed

Users of Windows can have screen resolutions ranging from
640×480 to 1024×768 or greater. For the same physical screen dimensions,
the pixels are larger or smaller depending on the selected resolution.
A window as defined in the Window painter will appear larger on
lower-resolution screens and smaller on higher-resolution screens.
A window that you position in the center of a Super VGA screen will
not appear centered on VGA.

On UNIX systems, the screen’s resolution is variable.
On Sun systems it is typically 1152×900 pixels. This larger size
means that windows positioned for smaller monitors will always be
visible. Windows that are centered on VGA screens will be placed
closer to the upper-left corner of a UNIX screen.

Controlling window placement

The GetEnvironment function can provide information about
the current screen resolution. Because PowerBuilder displays the window
when the Open event is finished, you can use information about the
screen to set a window’s position in its Open event.

The Open event is the perfect place for the window-positioning
code because:

  • You have to wait until PowerBuilder has
    created the window before you can modify its properties programmatically.
  • Putting information about positioning a window in
    its own Open event script encapsulates the method with the object.

In the script, you may want to reposition the window, change
the size of the window, or both.

Repositioning a window

The following sample script for a window’s Open event
calculates a position for the window that puts it in the center
of the screen. The X and Y coordinates being set are the coordinates
for the window’s upper-left corner.

window’s coordinates are in PBUs and the screen’s
measurements are reported in pixels. The PixelsToUnits function
makes the conversion:

Resizing a window to fit the screen

You can check the
window’s width and height to make sure the dimensions fit on
the current screen. For example, this code changes the window’s
width if it is too wide for the screen:

Resizing and window design

If you use this technique of resizing the window to fit, be
careful when you design your windows. Controls that are near the
edge of the window may disappear from view, forcing users to scroll
to see them–if they even realize the controls are there.
They can’t even scroll if scrollbars haven’t been

note.gif Provide scrollbars on resizable windows If your application resizes windows, enable scrollbars for
those windows so that the user can scroll to controls that get cut

Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x