have a program that fades out on mouse leave event.
but the problem is when the mouse goes in to a child of the form like a Button, it triggers the mouse leave event. so i set up this code.
private void Form1_MouseLeave(object sender, EventArgs e)
{
if (this.ClientRectangle.Contains(this.PointToClient(Cursor.Position)))
{
this.Opacity = 1.0;
}
else
{
int loopctr = 0;
for (loopctr = 100; loopctr >= 5; loopctr -= 10)
{
this.Opacity = loopctr / 99.0;
this.Refresh();
Thread.Sleep(100);
}
}
}
but the problem now is that the form often does not trigger the mouse leave event, looks to be because the buttons are so close to the form edges that it never registrer that the mouse left the form boundaries, probably because the mouse cursor is to fast and skips over the form when it leaves.
any suggestions on how to handel this?