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

Mouse move events

P: n/a
Hi,

I have an MDI app that allows user to create flowcharts.
User can drag flowchart objects (squares, rectangles,
elipses, etc) from the toolbar and put on a form. They
should be able to move the objects around on the form.

This is where the problem is, I have implemented this
using the mouse_down, mouse_up and mouse_move events of
the form. When user selects a object, I receive the
mouse_down mesg, in which I save the current mouse
coordinates. When user drags the object around I receive
mouse move events, in which I compute the distance that
the mouse has moved and move the object by that distance.
When the object is moved, that itself generates new
mouse_move events in the opposite direction. Why are these
events generated and how can I prevent them?

Thanks,
Suhas
Nov 15 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
I dealt with this myself. I made a form that would move with the mouse, below is the code from the Mouse Move event handler I am
using. It doesn't stop the additional event that occurs when you reposition the object. When I update my lastPos I set it to where
the next move event would put it so that it works out that no move at all occurs and prevents the event from firing a third time
from a single user action.

if (mouseDown)

{

int XOff = e.X - lastPos.X;

int YOff = e.Y - lastPos.Y;

Console.WriteLine("Xoff:{0} Yoff:{1}", XOff, YOff);

this.Left += XOff;

this.Top += YOff;

lastPos = new Point(e.X - XOff, e.Y - YOff);

}

"suhas" <su***@gosapphire.com> wrote in message news:05****************************@phx.gbl...
Hi,

I have an MDI app that allows user to create flowcharts.
User can drag flowchart objects (squares, rectangles,
elipses, etc) from the toolbar and put on a form. They
should be able to move the objects around on the form.

This is where the problem is, I have implemented this
using the mouse_down, mouse_up and mouse_move events of
the form. When user selects a object, I receive the
mouse_down mesg, in which I save the current mouse
coordinates. When user drags the object around I receive
mouse move events, in which I compute the distance that
the mouse has moved and move the object by that distance.
When the object is moved, that itself generates new
mouse_move events in the opposite direction. Why are these
events generated and how can I prevent them?

Thanks,
Suhas


Nov 15 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.