PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
This content has been translated automatically. Click here to view the French version.
  • 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
Used in an linked event with the mouse or the stylus (click code, hover code, left or right button pressed code, ...) returns the horizontal (X) position of the mouse cursor in relation to the control or the window considered.
You can find out:
  • the position of the mouse (or stylus) when left-clicking in an Image control (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
    // Survol souris de la fenêtre "FEN_Dessin"
    // Code optionnel de la fenêtre
    Message("Position de la souris: X: " + MouseXPos() + " Y: " + MouseYPos())
    Reports and Queries
    // Affiche un message différent selon l'endroit cliqué
    IF MouseXPos() > 25 THEN
    Info("A droite")
    ELSE
    Info("A gauche")
    END
    Syntax
    Reports and Queries

    Retrieving the mouse position in a window Hide the details

    <Result> = MouseXPos([<Marker>])
    <Result>: Integer
    • Horizontal position (or X-coordinate) of the mouse (or stylus) in pixels. By default, this position is given in relation to the top left corner of control on which the left mouse button was pressed.
    • -1 if an error occurred.
    <Marker>: Optional Integer constant
    Versions 17 and later
    Marker used to calculate the position:
    mpControl
    (Default value)
    Mouse position relative to the top left point of the hovered control (or of the window if the event is on the window).
    mpScreenMouse position in the screen (in relation to the top left corner of screen).
    mpWindowMouse position in relation to the top left corner of window.
    mpImageMouse position in the Image control (relative to the top left corner of the Image control).

    This constant should only be used when the MouseXPos function is called in an event associated with an Image control. Otherwise, the function MouseXPos will return -1.

    New in version 17
    Marker used to calculate the position:
    mpControl
    (Default value)
    Mouse position relative to the top left point of the hovered control (or of the window if the event is on the window).
    mpScreenMouse position in the screen (in relation to the top left corner of screen).
    mpWindowMouse position in relation to the top left corner of window.
    mpImageMouse position in the Image control (relative to the top left corner of the Image control).

    This constant should only be used when the MouseXPos function is called in an event associated with an Image control. Otherwise, the function MouseXPos will return -1.

    Marker used to calculate the position:
    mpControl
    (Default value)
    Mouse position relative to the top left point of the hovered control (or of the window if the event is on the window).
    mpScreenMouse position in the screen (in relation to the top left corner of screen).
    mpWindowMouse position in relation to the top left corner of window.
    mpImageMouse position in the Image control (relative to the top left corner of the Image control).

    This constant should only be used when the MouseXPos function is called in an event associated with an Image control. Otherwise, the function MouseXPos will return -1.

    Remarks
    Reports and Queries

    Error

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

    Miscellaneous

    • It is possible to know the vertical position of the mouse (or the stylus) thanks to the MouseYPos function.
    • MouseXPos 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: wd270obj.dll
    Minimum version required
    • Version 9
    This page is also available for…
    Comments
    Click [Add] to post a comment