Make Splash Screen for C# Windows Applications
What is Splash Screen?
A 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
Create new Project — C# Windows Form Application
Give a friendly name for your project and Create
Once done add a new form to your project where we are going to add our splash screen logo or image
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
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;
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
Source code can be downloaded from here — https://github.com/Gohulan/C-_Splash_Screen
Happy Coding !!