How to create a splash screen in a Windows Forms application?

I need to show the splash screen at the beginning of the application in a few seconds. Does anyone know how to implement this?

We will be very grateful for your help.

+50
c # winforms splash
Oct 31 2018-11-11T00:
source share
12 answers

Firstly, create your screensaver as a limitless, motionless form with an image on it, configured for the initial display in the center of the screen, in color, as you want. All this can be installed in the designer; in particular, you want:

  • Set the ControlBox, MaximizeBox, MinimizeBox, and ShowIcon properties to "False"
  • Set the StartPosition property to "CenterScreen"
  • Set the FormBorderStyle property to "None"
  • Set the MinimumSize and MaximumSize form to the same size as its initial size.

Then you need to decide where to show it and where to reject it. These two tasks must be performed from different sides of the main logic of running your program. This may be in your main () application program or perhaps in your main application form Load handler; wherever you create large, expensive objects, read settings from your hard drive, and usually take a lot of time to do things behind the scenes until the main application screen appears.

Then all you have to do is create an instance of your form, Show () and save a link to it during initialization of the launch. Once your main form loads, close ().

If an animated image is displayed on your splash screen, the window should also be a “double buffer”, and you need to be absolutely sure that all the initialization logic occurs outside the GUI stream (which means that you cannot have the main loading logic in the load handler mainform, you will need to create a BackgroundWorker or some other thread procedure.

+69
Oct. 31 '11 at 15:29
source share

The following example from Telerik uses the ShapedForm control, but change it to a regular Windows form. This is the easiest and best way I've seen.

http://www.telerik.com/support/kb/winforms/forms-and-dialogs/details/add-splashscreen-to-your-application

+10
Oct 13
source share

Below are some guidelines ...

  • Create a borderless form (this will be your splash screen)
  • When the application starts, start the timer (with an interval of several seconds)
  • Show your blank form
  • In Timer.Tick mode, stop timer and close the Splash form - then show your main application form

Give it back, and if you're stuck, come back and ask more specific questions about your problems.

+6
Oct. 31 '11 at 15:20
source share

simple and easy solution to create a screensaver

  1. open a new name using the "SPLASH" form
  2. change background image whatever
  3. select progress bar
  4. choose timer

now set the timer in the timer:

private void timer1_Tick(object sender, EventArgs e) { progressBar1.Increment(1); if (progressBar1.Value == 100) timer1.Stop(); } 

add a new form use name "FORM-1" and use the following command in FORM 1.

Note. The splash shape works until the form opens1

  1. add this library

     using System.Threading; 
  2. create function

     public void splash() { Application.Run(new splash()); } 
  3. use the following command when initializing, as shown 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/

+5
Sep 09 '15 at 1:31
source share

create a splash

 private void timer1_Tick(object sender, EventArgs e) { counter++; progressBar1.Value = counter *5; // label2.Text = (5*counter).ToString(); if (counter ==20) { timer1.Stop(); this.Close(); } } this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.SystemColors.GradientInactiveCaption; this.ClientSize = new System.Drawing.Size(397, 283); this.ControlBox = false; this.Controls.Add(this.label2); this.Controls.Add(this.progressBar1); this.Controls.Add(this.label1); this.ForeColor = System.Drawing.SystemColors.ControlLightLight; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.Name = "Splash"; this.ShowIcon = false; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.ResumeLayout(false); this.PerformLayout(); 

Then in your application

 sp = new Splash(); sp.ShowDialog(); 
+2
Sep 11 '12 at 6:27
source share

The other answers here are well covered, but you should know that Visual Studio has built-in functionality for splash screens. If you open the project properties for a Windows form application and see the "Application" tab, the "Screensaver:" option below. You simply choose which form in your application you want to display as a splash screen, and it will take care to show it when the application starts and hides after the main form is displayed.

You still need to adjust the shape as described above (with the correct borders, positioning, size, etc.).

+2
May 6 '14 at 7:27
source share

CodeProject has a pretty good splash screen .

It comes with

  • Fade in
  • Progress bar
  • Status icon
  • Fade out
  • Double click to decline

Recently, the author reviewed and updated the code. This is really a very rewarding job, and it is a collaboration between different developers with good ideas.

+2
Jul 17 '14 at 16:33
source share

First you must create a form with or without a border (border-less is preferred for this)

 public class SplashForm : Form { Form _Parent; BackgroundWorker worker; public SplashForm(Form parent) { InitializeComponent(); BackgroundWorker worker = new BackgroundWorker(); this.worker.DoWork += new System.ComponentModel.DoWorkEventHandler(this.worker _DoWork); backgroundWorker1.RunWorkerAsync(); _Parent = parent; } private void worker _DoWork(object sender, DoWorkEventArgs e) { Thread.sleep(500); this.hide(); _Parent.show(); } } 

On Main you should use this

  static class Program { [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new SplashForm()); } } 
+1
Oct 31 '11 at 15:30
source share

I need a splash screen that will be displayed until the main form of the program is ready for display, so timers, etc. I do not need. I also wanted it to be as simple as possible. My application starts with (abbreviated):

 static void Main() { Splash frmSplash = new Splash(); frmSplash.Show(); Application.Run(new ReportExplorer(frmSplash)); } 

Then ReportExplorer has the following:

 public ReportExplorer(Splash frmSplash) { this.frmSplash = frmSplash; InitializeComponent(); } 

Finally, after initialization is complete, everything:

 if (frmSplash != null) { frmSplash.Close(); frmSplash = null; } 

Maybe I missed something, but it seems a lot easier than thinning threads and timers.

0
Sep 06 '18 at 9:45
source share

It may be a little late to answer, but I would like to share my path. I found a simple way with threads in the main program for a winform application.

Suppose you have a splashscreen of your form with animation and your main, which has all of your application code.

  [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Thread mythread; mythread = new Thread(new ThreadStart(ThreadLoop)); mythread.Start(); Application.Run(new MainForm(mythread)); } public static void ThreadLoop() { Application.Run(new SplashScreenForm()); } 

In your main form in the constructor:

  public MainForm(Thread splashscreenthread) { InitializeComponent(); //add your constructor code splashscreenthread.Abort(); } 

Thus, the splash screen will only last for loading the main form.

The shape of your screen should have its own way of animating / displaying information. In my project, my splash screen launches a new stream, and every x milliseconds it changes the main image to another, which is a slightly different transmission, giving the illusion of rotation.

example of my splash screen:

 int status = 0; private bool IsRunning = false; public Form1() { InitializeComponent(); StartAnimation(); } public void StartAnimation() { backgroundWorker1.WorkerReportsProgress = false; backgroundWorker1.WorkerSupportsCancellation = true; IsRunning = true; backgroundWorker1.RunWorkerAsync(); } public void StopAnimation() { backgroundWorker1.CancelAsync(); } delegate void UpdatingThreadAnimation(); public void UpdateAnimationFromThread() { try { if (label1.InvokeRequired == false) { UpdateAnimation(); } else { UpdatingThreadAnimation d = new UpdatingThreadAnimation(UpdateAnimationFromThread); this.Invoke(d, new object[] { }); } } catch(Exception e) { } } private void UpdateAnimation() { if(status ==0) { // mypicture.image = image1 }else if(status ==1) { // mypicture.image = image2 } //doing as much as needed status++; if(status>1) //change here if you have more image, the idea is to set a cycle of images { status = 0; } this.Refresh(); } private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; while (IsRunning == true) { System.Threading.Thread.Sleep(100); UpdateAnimationFromThread(); } } 

Hope this helps some people. Sorry if I made some mistakes. English is not my first language.

0
Dec 03 '18 at 15:30
source share

Try this code

 public partial class ssplashscreen : Form { public ssplashscreen() { InitializeComponent(); } private void timer1_Tick(object sender, EventArgs e) { progressBar1.Increment(1); if (progressBar1.Value == 100) { timer1.Stop(); this.Hide(); Form frm = new login(); frm.Show(); } } } 
-2
Mar 17 '16 at 10:22
source share

Try this:

 namespace SplashScreen { public partial class frmSplashScreen : Form { public frmSplashScreen() { InitializeComponent(); } public int LeftTime { get; set; } private void frmSplashScreen_Load(object sender, EventArgs e) { LeftTime = 20; timer1.Start(); } private void timer1_Tick(object sender, EventArgs e) { if (LeftTime > 0) { LeftTime--; } else { timer1.Stop(); new frmHomeScreen().Show(); this.Hide(); } } } } 
-four
Aug 16 '18 at 13:20
source share



All Articles