469,945 Members | 2,225 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

Need to track mouse cords in order to move a Panel object

Jay
I need to be able to move a Panel on a windows Form at run time using
the mouse. I have tried adding a MouseDown event handler to the Panel
and then within the MouseDown handler adding a MouseMove event to the
Panel and then setting the Panel's Location to a new Point(x, y) with
x and y set to the mouse's x and y, but this does not work because the
MouseDown event of Panel only sends the cords of the mouse within that
Panel. I need to be able to move the Panel within the Form and need to
get the cords of the mouse within the Form in order to set the Panel's
Location.

I've also tried adding a MouseMove event to the Form when the Panel's
MouseDown event is called and then setting the Panel's Location based
on the cords of the Mouse events of the Form, but this has problems
because the Form doesn't receive mouse events while the cursor is
moving within the bounds of the Panel, cause the moving to be very
choppy.

Doesn't anyone have an idea as to how to handle this problem?

Thanks in advance,
I apologize if this has been asked already.
Jason
Nov 15 '05 #1
1 2634
When the mouse down is clicked you need to capture the mouse. Check out the
Control.Capture:

http://msdn.microsoft.com/library/de...pturetopic.asp

Mind the wrap

Regards
Lee
"Jay" <ja*********@yahoo.com> wrote in message
news:1e**************************@posting.google.c om...
I need to be able to move a Panel on a windows Form at run time using
the mouse. I have tried adding a MouseDown event handler to the Panel
and then within the MouseDown handler adding a MouseMove event to the
Panel and then setting the Panel's Location to a new Point(x, y) with
x and y set to the mouse's x and y, but this does not work because the
MouseDown event of Panel only sends the cords of the mouse within that
Panel. I need to be able to move the Panel within the Form and need to
get the cords of the mouse within the Form in order to set the Panel's
Location.

I've also tried adding a MouseMove event to the Form when the Panel's
MouseDown event is called and then setting the Panel's Location based
on the cords of the Mouse events of the Form, but this has problems
because the Form doesn't receive mouse events while the cursor is
moving within the bounds of the Panel, cause the moving to be very
choppy.

Doesn't anyone have an idea as to how to handle this problem?

Thanks in advance,
I apologize if this has been asked already.
Jason

Nov 15 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by John Champaign | last post: by
3 posts views Thread by AinO | last post: by
16 posts views Thread by Niels Jensen | last post: by
2 posts views Thread by Sam | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.