Scrolling in windows and user objects

For scrolling purposes, PowerBuilder divides the window content into 100 lines and 100 columns. Lines, columns, and pages for scrolling do not correlate with any visible aspect of the window (such as the viewable area).

A line or a column is the amount scrolled by clicking a scroll bar arrow. There are 100 lines and 100 columns in the control being scrolled, regardless of the area occupied by the content of the window or user object. To get to the end of the scroll bar, the user can click 100 times on the scroll bar arrow.

A page is the amount scrolled by clicking in the scroll bar, not on the scroll bar arrows.

Vertical versus horizontal scrolling

The procedures in the following sections define vertical scrolling, determined by the UnitsPerLine and LinesPerPage properties, but the same formulas apply to horizontal scrolling, determined by the UnitsPerColumn and ColumnsPerPage properties.

Relating scrolling to height of content

If you want the bottommost content in the window to be visible when the user reaches the end of the scroll bar, you need to set the value of the control's UnitsPerLine property so that 100 lines cover the entire contents.

To determine the value for UnitsPerLine:

  1. Resize the window to include all the contents.

  2. Look at the value of the Height option on the Position tab page of the window's Properties view.

    The height is shown in PowerBuilder units (PBUs).

  3. Divide 75% of the value of the Height option by 100 to get the number of PBUs each line should include:

    UnitsPerLine = height * .75 / 100

    Using 75% of the total height in this calculation keeps the end of the contents visible when the scroll bar reaches the end, instead of scrolling just out of sight.

Relating scrolling to page size

When the user clicks in the scroll bar, not on the scroll bar arrows, the control scrolls by a page. The page size is calculated using this formula:

pagesize = LinesPerPage * UnitsPerLine

Therefore, you can use the LinesPerPage property in conjunction with the UnitsPerLine property to set the page size for scrolling.

To determine the value for LinesPerPage

  1. Calculate the value of the UnitsPerLine property, as shown above.

  2. Size the window to its desired final size.

  3. Determine the height of the visible window area by looking at the value of the Height option on the Position tab page of the window's Properties view.

  4. Decide how much of the window you want to have scroll every time the scroll bar is clicked. This will give you the page size in PBUs.

    For example, if the visible window area height is 1200 PBUs and you want 1/4 of the window to scroll with each click, then the page size should be 300 PBUs.

  5. Calculate the value of the LinesPerPage property.

For example:

LinesPerPage = 300 / UnitsPerLine

Scrolling using a fixed number of clicks

Alternatively, if you want to let the user get to the bottom of the content in a given number of clicks, regardless of the visible window area, set LinesPerPage using this formula:

LinesPerPage = 100 / number of clicks