|
-
November 27th, 2010, 07:08 PM
#1
[RESOLVED]MouseMove event fires for no reason
Hi.
I'm writing an application which uses the MouseMove and Resize events.
Here's a skeleton of my code
Code:
private void MainForm_Resize(object sender, EventArgs e)
{
//do stuff
}
private void MainForm_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
//do some other stuff
}
}
Now, when I maximize the window by double clicking the blue bar at the top of the form, the MouseMove event fires, and the program enters the "//do some other stuff" code segment.
It happens because once I finish double clicking, the form is maximized, and since the mouse is now inside the bounds of the form, it threats my double-click as a click on the form (even though I finished doubled-clicking BEFORE the form size was changed).
Obviously, it's an unwanted behavior. I don't want to threat the double-click, which is supposed to maximize the window, as an actual click on the form.
So... I tried to fix the Resize event, by writing that instead:
Code:
private void MainForm_Resize(object sender, EventArgs e)
{
this.MouseMove -= new MouseEventHandler(MainForm_MouseMove);
//do stuff
this.MouseMove += new MouseEventHandler(MainForm_MouseMove);
}
but the MouseMove event still fires.
I even tried to call the Thread.Sleep() method inside the Resize event, but it didn't help either.
Is there a way to fix it?
Thanks.
Last edited by Talikag; November 28th, 2010 at 07:40 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|