OnWMMouseWheel - DfBaseDialog
Mouse Wheel event sent when a mouse wheel event occurs
Type: Event
Parameters
| Parameter | Type | Description |
|---|---|---|
| wParam | Integer | Window wParam passed by WM_MOUSEWHEEL |
| lParam | Integer | Window lParam passed by WM_MOUSEWHEEL |
Syntax
Procedure OnWMMouseWheel Integer wParam Integer lParam
Description
OnWMMouseWheel exposes the windows WM_MOUSEWHEEL event.
The parameters sent to the event wParam and lParam are the standard windows parameters for this event.
wParam
The high-order word indicates the distance the wheel is rotated, expressed in multiples or divisions of WHEEL_DELTA, which is 120. A positive value indicates that the wheel was rotated forward, away from the user; a negative value indicates that the wheel was rotated backward, toward the user.
The low-order word indicates whether various virtual keys are down. This parameter can be one or more of the following values.
| Col 1 | Col 2 |
|---|---|
| MK_CONTROL | The CTRL key is down. |
| MK_LBUTTON | The left mouse button is down. |
| MK_MBUTTON | The middle mouse button is down. |
| MK_RBUTTON | The right mouse button is down. |
| MK_SHIFT | The SHIFT key is down. |
| MK_XBUTTON1 | Windows 2000/XP: The first X button is down. |
| MK_XBUTTON2 | Windows 2000/XP: The second X button is down. |
lParam
The low-order word specifies the x-coordinate of the pointer, relative to the upper-left corner of the screen. The high-order word specifies the y-coordinate of the pointer, relative to the upper-left corner of the screen.
This is sent to the container object of the focus object when the mouse wheel generates an event. If you wish to handle this event, you should set Windows_Override_State to True, which will inform windows that the event has been handled. Doing this will stop the delegation of this message. By default this event does nothing, which causes the event to be sent to the parent container object, which will also do nothing and delegate.
If the focus object already handles the mouse wheel event, this event will not be sent to its parent container. cRichEdit, cTextEdit, List and Grid objects are examples of objects that handle this event.
This is a low level event and we do not expect that it will be used often. In advanced cases, it does provide the developer with a mechanism for responding to the mouse wheel.
// low level event sent from windows.
Procedure OnWmMouseWheel Integer wParam Integer lParam
Integer iWheelDelta iKeys iDelta iClicks
Move (low(abs(wParam))) to iKeys // any keys down when pressed
Move (hi(abs(wParam))) to iDelta // number of click units
If (wParam<0) Begin
Move (-iDelta) to iDelta // can be up or down
End
Get piWheelDelta to iWheelDelta // Current accumulated micro clicks
Move (iWheelDelta+iDelta) to iWheelDelta
// C_WHEELDATA is 120 as defined by MS as the delta to react to. Once click is usually 120
Move (iWheelDelta/C_WHEELDELTA) to iClicks // Number of clicks to react to
Set piWheelDelta to (mod(iWheelDelta,C_WHEELDELTA)) // remainder unused microclicks
// If we have enough Clicks send OnMouseWheel
If (iClicks<>0) Begin
Send OnMouseWheel iClicks iKeys
End
// tell windows that we've handled the event.
Set Windows_Override_State to True
End_Procedure
With the exceptions of the notifications for scrollbars and the mouse wheel evetns, all of the windows scrollbar interfaces can be accessed by creating external_functions. The events SetVScrollBox, SetHScrollBox and OnWMMouseWheel are provided to give you low level access to these events.