开发者

How to display Welcome Screen in Winform?

开发者 https://www.devze.com 2023-03-14 19:42 出处:网络
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.

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.开发者_C百科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?.

How to display Welcome Screen in Winform?


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


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());
    }


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消