Timothy Carter
Timothy Carter

Reputation: 15785

Fade splash screen in and out

In a C# windows forms application. I have a splash screen with some multi-threaded processes happening in the background. What I would like to do is when I display the splash screen initially, I would like to have it appear to "fade in". And then, once all the processes finish, I would like it to appear as though the splash screen is "fading out". I'm using C# and .NET 2.0. Thanks.

Upvotes: 5

Views: 11713

Answers (4)

Patrick Desjardins
Patrick Desjardins

Reputation: 140803

While(this.Opacity !=0)
{
    this.Opacity -= 0.05;
    Thread.Sleep(50);//This is for the speed of the opacity... and will let the form redraw
}

Upvotes: 3

slyprid
slyprid

Reputation: 1219

When using Opacity property have to remember that its of type double, where 1.0 is complete opacity, and 0.0 is completely transparency.

   private void fadeTimer_Tick(object sender, EventArgs e)
    {
        this.Opacity -= 0.01;

        if (this.Opacity <= 0)
        {
            this.Close();
        }            
    }

Upvotes: 7

user7116
user7116

Reputation: 64068

You could use a timer to modify the Form.Opacity level.

Upvotes: 11

RichS
RichS

Reputation: 3147

You can use the Opacity property for the form to alter the fade (between 0.0 and 1.0).

Upvotes: 3

Related Questions