469,127 Members | 1,425 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

MouseMove event triggered even if the mouse is not moving

Hello!

If I understand correctly, MouseMove event is triggered when the mouse moves
(ie when point changes).
I, however, found out that it's triggered even if the mouse is not moving.

What I did was:

In an empty form, I set the Form1.Text to "0" and added the following code
for Form1.MouseMove event.

private void Form1_MouseMove(object sender,
System.Windows.Forms.MouseEventArgs e)
{
int i;
i = int.Parse(this.Text);
i++;
this.Text = i.ToString();
}

I put the mouse cursor on the form and I didn't touch the mouse.
The Text (form's caption) kept increasing at irregular speed (but pretty
fast).

I thought that It could be triggered by a little shake of the mouse.
So I changed the code.

I added

private int x;
private int y;

private void Form1_MouseMove(object sender,
System.Windows.Forms.MouseEventArgs e)
{
if (Math.Abs(e.X - x) + Math.Abs(e.Y - y) > 0)
{
int i;
i = int.Parse(this.Text);
i++;
this.Text = i.ToString();
}
x = e.X;
y = e.Y;
}
Now the Text didn't increase.

My conclusion is that the MouseMove event can be triggered even if the point
was not changed.

By the way, my mouse is MS optical mouse.

Is this by design?

Sam
Nov 16 '05 #1
0 1699

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Tim Mulholland | last post: by
3 posts views Thread by Tim Mulholland | last post: by
3 posts views Thread by Crucifix | last post: by
3 posts views Thread by TyBreaker | last post: by
reply views Thread by Vincent | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.