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);
}
[quoted text, click to view] "suhas" <suhas@gosapphire.com> wrote in message news:05c701c362cd$a2458a70$a501280a@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
>
>