Sagotharan
Sagotharan

Reputation: 2626

How to display Welcome Screen in Winform?

I am doing win form project.(C#). In that project i am willing to add welcome screen. So i created a welcome screen. But, It want to show a few minitute and automatically closed and open login screen.

System.Threading.Thread.Sleep(1500);
            LogIn n = new LogIn();
            n.Show();

I try this code in form shown,load, activate events. BUt no use. Any one know what to do?.

My welcome screen -

Upvotes: 3

Views: 4084

Answers (3)

Uwe Keim
Uwe Keim

Reputation: 40746

In my opinion, you cannot create a splash screen in .NET for a .NET application:

The purpose of a splash screen is to distract users from long waiting times, until the application has been loaded, started and initialized.

Since a .NET application itself already has some startup time, there is no splash screen available within this time.

My solution

So in my applications, I am doing it the following way:

  1. Write a small, tiny native C++ application.
  2. Display a topmost bitmap (window with no borders) when the C++ application starts.
  3. Let the C++ application start the actual .NET application.
  4. The .NET application starts and when it is finished starting and initializing, it tells the C++ application to close. This is done through IPC.

The inter-process communication is done the following way:

  1. The C++ application writes a temporary file.
  2. When calling the .NET application, the file name is passed as a command line parameter.
  3. The C++ application polls regularly whether the file exists.
  4. The .NET application deletes the file as soon as the splash screen has to be hidden.
  5. The C++ application exists as soon as the temporary file does not exists anymore (or a timeout occurs).

I know this is not 100% perfect, it was the most suitable solution I came up since I started developing .NET applications, years ago.

Upvotes: 1

Orhan Cinar
Orhan Cinar

Reputation: 8410

Add a line for splash screen in Program.cs. Run a timer in splash screen and close the form.

private static void Main() {

        Application.EnableVisualStyles();

        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new FSplash()); // This is your splash form << added
        Application.Run(new FMain());
    }

Upvotes: 2

Druid
Druid

Reputation: 6453

Here's a tutorial explaining how to make a splash screen.

Upvotes: 4

Related Questions