S
Sam Sungshik Kong
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
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