Hi,

I'm having some difficulty and was trying to look for some help.

I have a button in a form that will change the background color when the mouse is over the button.

However, when I load my form and happen to have the mouse sitting on top of the button. I do not want the button changing color until I move the mouse.

As it stands right now, I'm using the OnMouseEnter and OnMouseLeave events to control when the button background color changes. I thought I would use OnMouseMove event to control when I would first change the background, however it appears a mouse movement is detected somehow when i just have the mouse sitting on top of the place where the button appears.

Here's a little snippet:

Code:
protected override void OnMouseMove(MouseEventArgs e)
{
this.MouseMove = true; base.OnMouseMove(e);
} protected override void OnMouseEnter(EventArgs e) {
if(this.MouseMove)
this.mouseOver = true;
this.Invalidate(); base.OnMouseEnter(e);
} protected override void OnMouseLeave(EventArgs e) {
this.mouseOver = false; this.Invalidate(); base.OnMouseLeave(e);
}
When this.mouseOver is true, the button will paint the background a different color.

Any help you can offer would be well appreciated.