Lazarus
Home
Forum
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
Graphics
»
GetCursorPos
Downloads
Daily Snapshots
FAQ
Wiki
Bugtracker
IRC channel
Developer Blog
Follow us on Twitter
Mailing List
Free pascal
Other languages
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
About donations (wiki)
Bookstore
Lazarus, the complete guide
Search
Advanced search
« previous
next »
Print
Pages: [
1
]
Author
Topic: GetCursorPos (Read 545 times)
Middlecope
New member
Posts: 9
GetCursorPos
«
on:
February 10, 2012, 02:33:33 am »
On a form I have a Paintbox.
On the Canvas of the Paintbox I draw an Ellipse(x1,y1,x2,y2)
If I click inside the ellipse in the PaintboxOnClick I state GetCursorPos(p).
Unfortunately the p.X and p.Y are outside the ranges [x1..x2] and [y1..y2]
Does anyone has an idea what I do wrong?
Thanks for your attention
Teunis
Logged
Leledumbo
Hero Member
Posts: 2989
Re: GetCursorPos
«
Reply #1 on:
February 10, 2012, 03:12:02 am »
AFAIK GetCursorPos returns cursor's global position (i.e. relative to the screen, not your application nor the specific control). Try calling
ScreenToClient
method from the specific control (TPaintBox in your case).
Logged
User137
Hero Member
Posts: 503
Re: GetCursorPos
«
Reply #2 on:
February 10, 2012, 03:18:27 pm »
Alternatively you can declare variables mouseX, mouseY, and update their values in PaintBoxOnMouseMove event, by X, Y parameters.
Or even easier by using onMouseDown (or onMouseUp) event instead of onClick. You have those cursor coordinates passed as X, Y there too.
«
Last Edit: February 10, 2012, 03:21:23 pm by User137
»
Logged
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
Graphics
»
GetCursorPos
Recent
StringGrid.LoadFromCSVFil...
by
tedsmith
[
Today
at 11:17:52 pm]
TaChart ternary plot func...
by
ccrause
[
Today
at 10:53:15 pm]
Things went wrong install...
by
garlar27
[
Today
at 10:46:45 pm]
Installing Lazarus/FPC on...
by
Bruce Mayo
[
Today
at 10:21:17 pm]
"Tween" two images
by
TheBlackSheep
[
Today
at 09:38:04 pm]
another bug?
by
circular
[
Today
at 08:36:16 pm]
BGRABitmap 5.7.1 won't co...
by
circular
[
Today
at 08:24:59 pm]
Q about capabilities of t...
by
ludob
[
Today
at 07:39:16 pm]
Cross Compile
by
Leledumbo
[
Today
at 05:23:05 pm]
Stable database?
by
BigChimp
[
Today
at 03:27:28 pm]