How to build splash screen in windows forms application?
simple and easy solution to create splash screen
- open new form use name "SPLASH"
- change background image whatever you want
- select progress bar
- select timer
now set timer tick in timer:
private void timer1_Tick(object sender, EventArgs e)
{
progressBar1.Increment(1);
if (progressBar1.Value == 100) timer1.Stop();
}
add new form use name "FORM-1"and use following command in FORM 1.
note: Splash form works before opening your form1
add this library
using System.Threading;
create function
public void splash() { Application.Run(new splash()); }
use following command in initialization like below.
public partial class login : Form { public login() { Thread t = new Thread(new ThreadStart(splash)); t.Start(); Thread.Sleep(15625); InitializeComponent(); enter code here t.Abort(); } }
http://solutions.musanitech.com/c-create-splash-screen/
First, create your splash screen as a borderless, immovable form with your image on it, set to initially display at the center of the screen, colored the way you want. All of this can be set from within the designer; specifically, you want to:
- Set the form's ControlBox, MaximizeBox, MinimizeBox and ShowIcon properties to "False"
- Set the StartPosition property to "CenterScreen"
- Set the FormBorderStyle property to "None"
- Set the form's MinimumSize and MaximumSize to be the same as its initial Size.
Then, you need to decide where to show it and where to dismiss it. These two tasks need to occur on opposite sides of the main startup logic of your program. This could be in your application's main() routine, or possibly in your main application form's Load handler; wherever you're creating large expensive objects, reading settings from the hard drive, and generally taking a long time to do stuff behind the scenes before the main application screen displays.
Then, all you have to do is create an instance of your form, Show() it, and keep a reference to it while you do your startup initialization. Once your main form has loaded, Close() it.
If your splash screen will have an animated image on it, the window will need to be "double-buffered" as well, and you will need to be absolutely sure that all initialization logic happens outside the GUI thread (meaning you cannot have your main loading logic in the mainform's Load handler; you'll have to create a BackgroundWorker or some other threaded routine.
Here are some guideline steps...
- Create a borderless form (this will be your splash screen)
- On application start, start a timer (with a few seconds interval)
- Show your Splash Form
- On Timer.Tick event, stop timer and close Splash form - then show your main application form
Give this a go and if you get stuck then come back and ask more specific questions relating to your problems