Mouse position

  • Thread starter Thread starter Mathieu Chavoutier
  • Start date Start date
M

Mathieu Chavoutier

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 ?
 
You have to convert to client co-ordinates using cusor position

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

Shak.
 
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.
 
Back
Top