ConnectScrollBarNotify

>>-aMessageExtensions~ConnectScrollBarNotify(--id--,--"--+-UP--------+--"-->
                                                         +-DOWN------+
                                                         +-TOP-------+
                                                         +-BOTTOM----+
                                                         +-PAGEUP----+
                                                         +-PAGEDOWN--+
                                                         +-DRAG------+
                                                         +-ENDSCROLL-+
                                                         +-POSITION--+

>--+---------------+--)---------------------------------------------------><
   +-,--msgToRaise-+


The ConnectScrollBarNotify method connects a particular WM_NOTIFY message for a scroll bar with a method. The WM_NOTIFY message informs the dialog that an event has occurred with regard to the scroll bar.

Arguments:

The arguments are:

id

The ID of the scroll bar of which a notification is to be connected to a method.

event

The event to be connected with a method:

UP

The scroll bar was scrolled to the left or up by one unit.

DOWN

The scroll bar was scrolled to the right or down by one unit.

TOP

The scroll bar was scrolled to the upper left.

BOTTOM

The scroll bar was scrolled to the lower right.

PAGEUP

The scroll bar was scrolled to the left or up by one page size.

PAGEDOWN

The scroll bar was scrolled to the right or down by one page size.

DRAG

The scroll bar has been dragged.

ENDSCROLL

Scrolling has been ended, that is, the appropriate key or mouse button has been released.

POSITION

The scroll bar was scrolled to an absolute position (the left mouse button has been released).

msgToRaise

The message that is to be sent whenever the specified notification is received from the scroll bar. Provide a method with a matching name. If you omit this argument, the event is preceded by On.

Return value:

The return codes are:

0

No error detected.

-1

The resource ID could not be resolved or the event argument is incorrect.

1

The messages was not connected correctly.

Example:

The following example connects the POSITION event with method OnPosition, which extracts the new position from the notification arguments and stores it for the scroll bar. It also displays the new position and the event type for POSITION, which is to be 4:

::class MyDlgClass subclass UserDialog inherit MessageExtensions

::method InitDialog
  self~InitDialog:super(...)
  self~ConnectScrollBarNotify("MYSCROLL", "POSITION")

::method OnPosition
  use arg ev_pos, hnd
  pos = .DlgUtil~hiWord(ev_pos)

  -- redraw scroll bar with new position
  self~GetScrollBar("MYSCROLL")~setPos(pos,1)

  say "Pos:" pos
  say "Verify event code (should be 4):" .DlgUtil~loWord(ev_pos)

  1. The method can only be called after the scroll bar was created by Windows. A good location for this connection is the InitDialog method.

  2. The event-handling methods receive two arguments: an event-position pair and the handle to the scroll bar. You can retrieve the scroll bar position by extracting the high-order word.

    Example:

    ::method Handler
      use arg ev_pos, handle
      position = .DlgUtil~hiWord(ev_pos)

    If the user changed the scroll bar position, you must set the scroll bar position with setPos to keep the selected position.