Returns the vertical position (Y) 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)
- The mouse position can also be obtained with CursorPos. CursorPos should only be used to modify the mouse position.
- This function should only be used in the events of controls hovered with the mouse.
- MouseYPos returns the last known position of the finger on the screen.
Retrieving the mouse position in a window Hide the details
<Result> = MouseYPos([<Marker>])
- Vertical position (Y-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 control or window, depending on where the event occurs.|
|mpImage||Mouse position in the image (relative to the upper-left corner of the image). |
This constant should only be used when MouseYPos is called in an event associated with an Image control. Otherwise, MouseYPos 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