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.开发者_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?.
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:
- Write a small, tiny native C++ application.
- Display a topmost bitmap (window with no borders) when the C++ application starts.
- Let the C++ application start the actual .NET application.
- 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:
- The C++ application writes a temporary file.
- When calling the .NET application, the file name is passed as a command line parameter.
- The C++ application polls regularly whether the file exists.
- The .NET application deletes the file as soon as the splash screen has to be hidden.
- 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.
精彩评论