Delphi/Lazarus: Determine Mouse Position
Question by Guest | 2016-01-18 at 13:33
Is there any possibility to specify the current position of the mouse in Lazarus or Delphi?
For example in terms of the recent X and Y coordinates on the screen?
Related Topics
Delphi/Lazarus: Is the ALT, SHIFT or CTRL key pressed?
Tutorial | 0 Comments
Pipette: Fetch Colors from all over the Screen
Tutorial | 0 Comments
Delphi/Lazarus: How to set up a Link to a Website in an Application
Tutorial | 0 Comments
Delphi/Lazarus: 3 Ways to round a Number to X Decimal Places
Tutorial | 7 Comments
Lazarus: Match FormDropFiles with a specific ListView
Tutorial | 0 Comments
Delphi/Lazarus: Command Line Parameter Tutorial Part 1: Sending
Tutorial | 0 Comments
Delphi: Global Treatment of Errors (Exceptions)
Tutorial | 0 Comments
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.
Yes, it is possible. There are even several ways to do so. First of all, you can always use Mouse.CursorPos.X and Mouse.CursorPos.Y to get to the current mouse position on the screen. For example like that:
In this example, we are using a Timer in order to read out the mouse position at regular intervals and to show them as caption of the Form.
However, many controls are offering directly the event OnMouseMove that is automatically making available the variables X and Y. Among others, also each Form offers this event, so that you can also retrieve the mouse position in the following way:
In this example, we are showing the current mouse position as caption of a Label every time the mouse moves over the Form.
2016-01-18 at 18:54