473,405 Members | 2,282 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Mouse move events

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
1 7631
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: John Champaign | last post by:
Hi all, I'm working on an educational applet for a child with special needs. He's got a bit of a trick to make my life more difficult... To interact with the applet he needs to click on...
0
by: Stephen Williams | last post by:
I am migrating a VB 6 PictureBox control to VB.NET. In VB 6, this control modified its border style during the mouse down and up events to provide user feedback that it was selected. Once...
3
by: Csaba2000 | last post by:
I have set onmousedown to change the cursor, but this setting is ignored (IE 5.5; NN 6.1 on Win 2K Pro) until the mouse is either moved or the mouse button is released. On Opera 7.01, the setting...
3
by: red | last post by:
mouse events when the mouse is on a "child control" hi everyone; my problem: I have a userControl in this usercontrol, I have a child control (a button) when the mouse moves over the...
1
by: Jay | last post by:
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...
3
by: AinO | last post by:
Hi, (VS2003/c# - System.Windows.Forms) Is there a way to know (have an event triggered) if the mouse leaves a form, if this form's client area is completly covered with child controls ? I...
5
by: Nick | last post by:
Hey guys, I have 2 events on a windows forms datagrid, the mouse move as well as the double click events. What's happening is that when I double click on a row in the grid, the mouse move event...
0
by: hmm | last post by:
Hi all I have two problems: Problem #1: I'm using a .NET Form with the property 'FormBorderStyle' set to 'None'. The idea is to completely cover the area of that Form with a UserControl. In...
1
by: Narcolessico | last post by:
Hi, I'm writing on Linux an application which needs to move the mouse pointer and simulate button clicks (better: button press and release events separately, e.g. to do drag&drop). I found...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.