ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Standard functions / Windows functions / Mouse functions
  • Error
  • 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 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)
Remarks:
    Example
    Reports and Queries
    // "WIN_Drawing" window hovered by the mouse
    // Optional code of the window
    Message("Position of the mouse: X: " + MouseXPos() + "Y: " + MouseYPos())
    Reports and Queries
    // Displays a different message according to the location clicked
    IF MouseYPos() < 25 THEN
    Info("At the top")
    ELSE
    Info("At the bottom")
    END
    Syntax
    Reports and Queries

    Retrieving the mouse position in a window Hide the details

    <Result> = MouseYPos([<Marker>])
    <Result>: Integer
    • 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:
    mpControl
    (Default value)
    Mouse position relative to the upper-left corner of the control or window, depending on where the event occurs.
    mpImageMouse 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.
    mpScreenMouse position in the screen (relative to the upper-left corner).
    mpWindowMouse position relative to the upper-left corner of the window.

    Remarks
    Reports and Queries

    Error

    The main error codes are as follows:
    • No window is opened.
    • No mouse click is performed.
    • MouseYPos is not called in a mouse event.
    • The click code is executed by Execute or ExecuteProcess.
    Reports and Queries

    Miscellaneous

    • You can get the horizontal position of the mouse or stylus with MouseXPos.
    • MouseYPos used in the selection code of row or table always returns 0.
    Related Examples:
    The drawing functions Unit examples (WINDEV): The drawing functions
    [ + ] Using the main drawing functions of WINDEV to:
    - Initialize an Image control for drawing
    - Draw simple shapes
    - Write a text into a drawing
    - Change the color in a drawing
    Component: wd290obj.dll
    Minimum version required
    • Version 9
    This page is also available for…
    Comments
    Click [Add] to post a comment

    Last update: 06/22/2023

    Send a report | Local help