By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,974 Members | 1,834 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,974 IT Pros & Developers. It's quick & easy.

Mouse position

P: n/a
I want to make a tool to design (like paint).
So, I want to know the position of the mouse.

Cursor.Position.X gives me that information. But, when I draw a picture, it
is not at the good place
e.Graphics.DrawImage(newImage, new Rectangle(x, y, 32, 32));

I think it is because Cursor.Position.X is an absolute coordonate, and
DrawImage takes a relative coordonate.

So, how can I get the true position on the screen ?
Nov 16 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
You have to convert to client co-ordinates using cusor position

testControl.PointToClient(Point (Cursor.Position.X ,Cursor.Position.Y));

Shak.
"Mathieu Chavoutier" <no****@no.spam> wrote in message
news:Oa**************@TK2MSFTNGP11.phx.gbl...
I want to make a tool to design (like paint).
So, I want to know the position of the mouse.

Cursor.Position.X gives me that information. But, when I draw a picture, it is not at the good place
e.Graphics.DrawImage(newImage, new Rectangle(x, y, 32, 32));

I think it is because Cursor.Position.X is an absolute coordonate, and
DrawImage takes a relative coordonate.

So, how can I get the true position on the screen ?

Nov 16 '05 #2

P: n/a
In article <Oa**************@TK2MSFTNGP11.phx.gbl>, no****@no.spam
says...
I want to make a tool to design (like paint).
So, I want to know the position of the mouse.

Cursor.Position.X gives me that information. But, when I draw a picture, it
is not at the good place
e.Graphics.DrawImage(newImage, new Rectangle(x, y, 32, 32));

I think it is because Cursor.Position.X is an absolute coordonate, and
DrawImage takes a relative coordonate.

So, how can I get the true position on the screen ?


See the Control.PointToClient method.

--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele
Nov 16 '05 #3

P: n/a
PointToClient works, thanks for both.
Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.