468,133 Members | 1,168 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,133 developers. It's quick & easy.

Form cursor X and Y pixel coordinates

Hello,
I want to try to retrieve the cursor position x and y relative to the form
the cursor is over.

The way I am doing it now is:

1. Retrieve the left and top position of the form relative to the desktop
2. Retrieve the desktop cursor position.
3. Take the difference of the forms left and top position. Adjust the
desktop cursor position based on this.

Is there an easier way? Is there a property within System.Windows.Forms
/controls that already calculates this?

Sorry if this is a stupid question.

Sincerely,

Dan

Nov 15 '05 #1
1 12882
see http://www.syncfusion.com/FAQ/WinFor...c50c.asp#q597q

Point ptCursor = Cursor.Position;
ptCursor = PointToClient(ptCursor);

hth, mike
"Dan H." <Da**@projectavatar.com> wrote in message
news:uL*************@TK2MSFTNGP12.phx.gbl...
Hello,
I want to try to retrieve the cursor position x and y relative to the form the cursor is over.

The way I am doing it now is:

1. Retrieve the left and top position of the form relative to the desktop 2. Retrieve the desktop cursor position.
3. Take the difference of the forms left and top position. Adjust the desktop cursor position based on this.

Is there an easier way? Is there a property within System.Windows.Forms /controls that already calculates this?

Sorry if this is a stupid question.

Sincerely,

Dan

Nov 15 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Danny | last post: by
11 posts views Thread by Jozef | last post: by
4 posts views Thread by Tomasz Bak | last post: by
30 posts views Thread by Chaos | last post: by
1 post views Thread by akscol | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.