Returns the horizontal position (X) of the mouse cursor relative to the specified window or control. Used in a mouse or stylus process (click, hover, left or right button down, etc.).
You can get:
- the position of the mouse (or stylus) when an Image control is clicked (function used in the "Click" event of the Image control).
- the position of the mouse (or stylus) when hovering over a window (function used in the optional "Mouse hover" event of a window).
- This function should only be used in the events of controls hovered with the mouse.
- MouseXPos returns the last known position of the finger on the screen.
Retrieving the mouse position in a window Hide the details
<Result> = MouseXPos([<Marker>])
- Horizontal position (X-coordinate) of the mouse or stylus, in pixels. By default, this position is relative to the upper-left corner of the control on which the left mouse button was pressed.
- -1 if an error occurred.
<Marker>: Optional Integer constant
Marker used to calculate the position:
|Mouse position relative to the upper-left corner of the hovered control or window, depending on where the event occurs.|
|mpImage||Mouse position in the Image control (relative to the upper-left corner). |
This constant should only be used when MouseXPos is called in an event associated with an Image control. Otherwise, MouseXPos will return -1.
|mpScreen||Mouse position in the screen (relative to the upper-left corner).|
|mpWindow||Mouse position relative to the upper-left corner of the window.|
This parameter is not available.
Unit examples (WINDEV): The drawing functions