Make Splash Screen for C# Windows Applications

Copper Contributor

What is Splash Screen? 

splash screen usually appears while a application or program launching, it normally contains the logo of the company or sometimes some helpful information about the development. It can be an animation or image or logo or etc. 

You can see lot of mobile application developers has done it but it's not common in Windows desktop applications. Making the splash screen is not a big deal if you are familiar with C# application development. Here I ll show you the steps of creating it.

 

As usual idle is Visual Studio 2019

1.JPG

Create new Project - C# Windows Form Application

2.JPG

Give a friendly name for your project and Create

3.JPG

Once done add a new form to your project where we are going to add our splash screen logo or image

4.JPG

Once done, I am adding a progress bar and image to the screen, also change the following in the form properties

Auto Size Windows Screen - False

Control Box - False

Windows Startup Location - Center

In the progress bar properties change the style to Marquee

Marquee animation speed to - 50

5.JPG

Now we have finished the designing of the splash screen form, will continue to add the screen in the startup of the project and debug now

Go to the main screen form coding cs file

Here I have used the following System libraries which  available in .NET 4.0 on wards

using System.Threading;
using System.Threading.Tasks;

6.JPG

Now in the public start the Splash screen form by calling like this method, 

public void StartForm()
{
Application.Run(new SplashScreen());
}

 

In the Main screen Initialize the component thread function for the splash screen form like this 

Thread t = new Thread(new ThreadStart(StartForm));
t.Start();
Thread.Sleep(5000);
InitializeComponent();
t.Abort();

 

Total coding will be as following 

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Splash_Screen_nTest
{
public partial class MainScreen : Form
{
public MainScreen()
{
Thread t = new Thread(new ThreadStart(StartForm));
t.Start();
Thread.Sleep(5000);
InitializeComponent();
t.Abort();
}

public void StartForm()
{
Application.Run(new SplashScreen());
}

private void MainScreen_Load(object sender, EventArgs e)
{

}
}
}

 

Once u debugged the application it will run as expected

8.JPG

 

Source code can be downloaded from here - https://github.com/Gohulan/C-_Splash_Screen

 

Happy Coding !!

 

1 Reply
thanks you!