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

MouseMove event triggered even if the mouse is not moving

P: n/a
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
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.