MouseWheel Event

Purpose

Occurs when the user moves the mousewheel in a Form.

Syntax

Sub Form_MouseWheel([index,] Buttons&, Delta%, MseX%, MseY%)

Form:Form Object
Buttons&:Short integer exp
Delta%, MseX, MseY:iexp

Description

FormReturns a Form object expression.

index - Returns an integer that uniquely identifies a Form if it's in a Form() array.

Button - Indicates whether various virtual keys are down. This parameter can be any combination of the following values:

MK_CONTROL Set if the ctrl key is down.
MK_LBUTTON Set if the left mouse button is down.
MK_MBUTTON Set if the middle mouse button is down.
MK_RBUTTON Set if the right mouse button is down.
MK_SHIFT Set if the shift key is down.

Delta - Indicates the distance that 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.

MseX, MseY - Returns a number that specifies the current location of the mouse pointer in pixels - this is relative to the desktop rather than the window/form over which the mouse is hovering; to get the X and Y co-ordinates relative to the object, use MouseX and MouseY,.

Example

Global Int x = ((Screen.x - 100) / 2), y = ((Screen.y - 14) / 2)

OpenW Full 1

Ocx Label lb = "***---***", x, y, 100, 14 : lb.Alignment = 2

Do

Sleep

Until Me Is Nothing

 

Sub Win_1_MouseWheel(Buttons&, Delta%, MseX%, MseY%)

If Buttons& = 0               // Vertical movement

y = y - (Delta% / 4)

Else If Buttons& = MK_SHIFT   // Horizontal movement

x = x - (Delta% / 4)

EndIf

// Keep label in-screen (although it does go behind the taskbar)

x = Max(0, Min(x, Screen.x - 100))

y = Max(0, Min(y, Screen.y - 14 - Screen.cyCaption))

lb.Move x, y

EndSub

Remarks

See Also

Form, Click, DblClick, MouseDown

{Created by Sjouke Hamstra; Last updated: 18/09/2021 by James Gaite}