ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / Windows functions / Mouse functions
  • Calculating the mouse position
  • Miscellaneous
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Returns and modifies the position of the mouse cursor.
Remark: To get the position of the mouse cursor, it is recommended to use MouseXPos and MouseYPos.
Example
Res is int = CursorPos(cpClient)
IF Res <> -1 THEN
Message("Position X = " + LoWord(Res) + "Position Y = " + HiWord(Res))
END
Syntax
<Result> = CursorPos([<Marker>, ] <X Position> , <Y Position>)
<Result>: Integer
Position of the mouse (the coordinates are returned by HiWord and LoWord).
  • Current position if <X Position> and <Y Position> are not specified.
  • Previous position if <X Position> and <Y Position> are specified.
  • -1 if an error occurs (position of the mouse outside the requested marker for example).
<Marker>: Optional integer constant
Indicates the marker used to calculate the position:
cpClientMouse position in relation to the client area of the window with focus.
Client Area = window without title bar, menu bar and border.
cpScreen
(Default value)
Position of the mouse in relation to the screen.
cpWindowPosition of the mouse in relation to the window with focus.
<X Position>: Real
New horizontal position in the selected marker.
<Y Position>: Real
New vertical position in the selected marker.
Remarks

Calculating the mouse position

To find out the horizontal and vertical position of the mouse from the result, you must use HiWord and LoWord.
The low byte of <Result> is used to get the horizontal position (X) of the mouse.
The high byte of <Result> is used to get the vertical position (Y) of the mouse. If an error occurs, X and Y are equal to -1.
The coordinates are relative to the top left corner of the selected marker.

Miscellaneous

  • MouseXPos and MouseYPos respectively return the horizontal and vertical positions of the mouse in relation to the control where a left mouse click was performed.
  • You can, for example, calculate the position of the mouse cursor in a timer in order to always display this position on the screen.
Component: wd290std.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 05/26/2022

Send a report | Local help