Scroll Bar Methods

The following methods are used to set or get the behavior of a scroll bar. You can connect scroll bars with numerical entry fields to edit the value with the mouse.

GetSBRange

>>-aBaseDialog~GetSBRange(--id--)-----------------------------><


The GetSBRange method returns the range of a scroll bar control. It returns the two values (minimum and maximum) in one string, separated by a blank.

Protected:

This method is protected.

Arguments:

The only argument is:

id

The ID of the scroll bar.

Example:

The following example demonstrates how to get the minimum and the maximum values of the scroll bar:

     .
     .
     .
::method DumpSBRange
SBrange = self~GetSBRange(234)
parse var SBrange SBmin SBmax
say SBmin " - " SBmax

SetSBRange

                                                   +-1------+
>>-aBaseDialog~SetSBRange(--id--,--min--,--max--,--+--------+--)-><
                                                   +-redraw-+


The SetSBRange method sets the range of a scroll bar control. It sets the minimum and maximum values.

Protected:

This method is not intended to be used outside of the BaseDialog class.

Arguments:

The arguments are:

id

The ID of a scroll bar control.

min

The minimum value.

max

The maximum value.

redraw

A flag indicating whether (1) or not (0) the scroll bar should be redrawn. The default is 1.

Example:

The following example allows the scroll bar to take values between 1 and 10:

MyDialog~SetSBRange(234, 1, 10, 1)

GetSBPos

>>-aBaseDialog~GetSBPos(--id--)-------------------------------><


The GetSBPos method returns the current value of a scroll bar control.

Arguments:

The only argument is:

id

The ID of the scroll bar.

SetSBPos

                                         +-1------+
>>-aBaseDialog~SetSBPos(--id--,--pos--,--+--------+--)--------><
                                         +-redraw-+


The SetSBPos method sets the current value of a scroll bar control.

Protected:

This method is protected.

Arguments:

The arguments are:

id

The ID of the scroll bar.

pos

The value to which you want to set the scroll bar. It must be within the defined range.

redraw

A flag indicating whether (1) or not (0) the scroll bar should be redrawn. The default is 1.

CombineELwithSB

>>-aBaseDialog~CombineELwithSB(--elid--,--sbid--+-------------------------+--)-><
                                                +-,--+------+--+--------+-+
                                                     +-step-+  +-,--pos-+


The CombineELwithSB method connects an entry line with a scroll bar such that each time the slider of the scroll bar is moved, the value of the entry field is changed. This method must be used in a method registered with ConnectScrollBar.

Arguments:

The arguments are:

elid

The ID of the entry line.

sbid

The ID of the scroll bar.

step

The size of one step. If, for example, step is 3 and the current position is 4, the next position is 7.

pos

If the step value is zero, this sets the position of the scroll bar and entry line. Use it in the method registered for drag.

Example:

The following example continues the example of ConnectScrollBar. In the registered methods an entry line (251) is combined with the scroll bar (255).

::method Increase
self~CombineELwithSB(251,255,+20)
::method Decrease
self~CombineELwithSB(251,255,-20)
::method Drag
use arg wparam, lparam                  /* wparam=position */
self~CombineELwithSB(251,255,0,wparam)

DetermineSBPosition

>>-aBaseDialog~DetermineSBPosition(--id--,--posdata--+----------------------------+--)-><
                                                     +-,--+--------+--+---------+-+
                                                          +-single-+  +-,--page-+


The DetermineSBPosition method calculates and sets the new scroll bar position based on the position data retrieved from the scroll bar and the step information.

Protected:

This method is protected.

Arguments:

The arguments are:

id

The ID of the scroll bar.

posdata

The position information sent with the connected scroll bar event.

single

This number is added (or subtracted if negative) to the current position for a single step. If omitted, the single step size is 1.

page

This number is added (or subtracted if negative) to the current position for a page step. If omitted, the page step size is 10.

Return value:

The new scroll bar position.

Example:

The following example demonstrates how to update the scroll bar position. Each time the ScrollBarEventHandler is called by an event for scroll bar SB_SIZE, the position of the scroll bar is calculated and updated. posdata is sent along with the scroll bar event.

   /* Method ScrollBarEventHandler is connected to item SB_SIZE */
::method ScrollBarEventHandler
    use arg posdata, sbwnd
    pos = self~DetermineSBPosition("SB_SIZE",posdata,1,25)
    return pos