Splash screens can easily provide a professional look to a program and allow startup code to run in the background. Especially when using web services, it can take time to contact the web service and get an instance of it instantiated. Instead of making the user stare at blank windows until the program is ready, why not show a splash screen with a text display showing the progress? This tutorial is written in C#, but of course the principle can be applied in just about any programming language.

1. Create the Project
First, create a new project to demonstrate the splash screen. The form in this project will be the startup form for the project. I'll refer to this main form as Form1.

2. Splash Form
The splash form is a regular Windows Form with no border or title bar. Add a new form to the project called frmSplash.cs. Set the following properties of the form:
  • FormBorderStyle = None
  • Modifiers = Public
  • StatPosition = CenterScreen
    Next, add a label to the form and name it lblStatus. Eventually it will be a good idea to add a logo to the form and make the label blend in by setting the backcolor to match the image and by setting the font color. For now we'll just focus on the code.

    3. Main Form Code
    In the load method for Form1, add the following code to control the splash screen:
    private void Form1_Load(object sender, System.EventArgs e)
    {
      // Display the splash screen
      frmSplash SplashScreen = new frmSplash();
      SplashScreen.Show()
    
      // show the splash form and update text as events occur
      SplashScreen.lblStatus.Text = "Helpful information here";
      SplashScreen.lblStatus.Refresh();
      // call the method to perform the action
    
      // Repeat the update of the text and calling methods until program is ready to run.
    
      // Close the splash screen
      SplashScreen.Close()
    }
    


    That's all there is to it. It's a very simple way to add that professional touch to your programs while getting some time consuming code out of the way up front.

    This code was accepted as a tutorial on Devhood!

    Disclaimer:
    By installing this software, you assume complete responsibility for any damage that may occur to your system or your oldest child.  I assume no liability.  Besides, if you tried to sue me you wouldn't get much.  May cause cancer in pregnant lab rats on rainy days in Arkansas. Violators will be persecuted. Do not pass Go, do not collect $200, go directly to jail. An apple a day keeps the doctor away. Caffeine-free (although I am probably not). Look both ways before crossing the road. Don't put that quarter in your mouth, you don't know where it's been. Do not use in areas of high radiation. Do not use while being chased by a rabid African tiger (a healthy one maybe, but not a rabid one). I am not responsible for any lost or stolen brain cells. And last, but not least, have fun!