>>-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.
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.
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~InitDialog:super(...) self~ConnectScrollBarNotify("MYSCROLL", "POSITION") ::method OnPosition use arg ev_pos, hnd pos = ev_pos % "10000"~x2d self~GetScrollBar("MYSCROLL")~SetPos(pos,1) /* redraw scroll bar with new position */ say "Pos=" pos ", event code to verify=" BinaryAnd(ev_pos, , "0x0000FFFF") "(expected 4)"
The method can only be called after the scroll bar was created by Windows. A good location for this connection is the InitDialog method.
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 = ev_pos % "10000"~x2dIf the user changed the scroll bar position, you must set the scroll bar position with SetPos to keep the selected position.