Returns the current X coordinate of the mouse pointer.
mx% = MouseX
my% = MouseY
mx%, my%:ivar
Returns the mouse position relative to the client area of the window.
Ocx controls that are aligned at the border of the parent form (using Align) change the Scale settings of the parent. ScaleLeft and ScaleTop are set to the top-left pixel of the uncovered client area of the form. ScaleWidth and ScaleHeight are set to width and height of the uncovered area. The mouse coordinates returned from MouseX, MouseY and that are passed in the forms MouseMove, MouseUp, and MouseDown events are relative to the new origin.
OpenW 1, 100, 100, 200, 200, 0
Local ax%, ay%, mx%, my%
Do
Sleep
ax% = mx%, ay% = my%
mx% = MouseSX, my% = MouseSY
If (ax% <> mx%) || (ay% <> my%)
Text 10, 10, "Mouse moving on the screen in"
Text 10, 30, "X-direction" + Space(20) + "Y-direction"
Text 10, 50, Space$(999)
Text 20, 50, Str$(mx%) + Space(30) + Str$(my%)
If mx% - 2 < TwipsToPixelX(Win_1.Left) Or mx% + 2 > TwipsToPixelX(Win_1.Left + Win_1.Width) Or _
my% - 2 < TwipsToPixelY(Win_1.Top) Or my% + 2 > TwipsToPixelY(Win_1.Top + Win_1.Height)
Text 10, 90, Space$(999)
Text 10, 110, Space$(999)
Text 10, 130, Space$(999)
EndIf
EndIf
Loop Until MouseK = 2
CloseW 1
Sub Win_1_MouseMove(Button&, Shift&, x!, y!)
Text 10, 90, "Mouse moving in the window at"
Text 10, 110, "X-direction" + Space(20) + "Y-direction"
Text 10, 130, Space$(999)
Text 20, 130, Str$(x!) + Space(30) + Str$(y!)
EndSub
A real application would use the _MouseMove event sub.
DefMouse, Mouse, MouseSX, MouseK
{Created by Sjouke Hamstra; Last updated: 19/10/2014 by James Gaite}