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.


The arguments are:


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


The event to be connected with a method:


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


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


The scroll bar was scrolled to the upper left.


The scroll bar was scrolled to the lower right.


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


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


The scroll bar has been dragged.


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


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


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:


No error detected.


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


The messages was not connected correctly.


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~ConnectScrollBarNotify("MYSCROLL", "POSITION")

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

  -- redraw scroll bar with new position

  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.


    ::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.