Thursday, January 15, 2009

Make Form Auto Opacity

To create form fade out or fade in, you can change the value of opacity property by repetition. (Increase or decrease value by 0.1)

using System.Threading;

private void Form1_MouseHover(object sender, EventArgs e)
{
Point ptCursor = Cursor.Position;
ptCursor = PointToClient(ptCursor);
if (this.ClientRectangle.Contains(ptCursor))
{
i = this.Opacity;
while (i <= 1)
{
i += 0.1;
this.Opacity = i;
Thread.Sleep(30);
}
}
}

No comments: