65.9K
CodeProject is changing. Read more.
Home

Splash Screen Control in WinForm C#

starIconstarIcon
emptyStarIcon
starIcon
emptyStarIconemptyStarIcon

2.33/5 (4 votes)

Dec 20, 2014

CPOL
viewsIcon

24685

Step by step making of splash screen for Windows Form Application

Introduction

Splash Screen Control, using this tutorial, it'll be easy to make an opacitic Splash Screen .

Splash Screen is the screen that you can use as your opening page or closing page with your Company logo of icon, image.

Full Method

By following this point, you can easily make your own.

  1. First open a new WinFrom, and name it Splash Screen.

  2. By default, it will make you an empty Form. By right clicking, you can find properties of that Form.

  3. Make the Form Borderless by selecting Border style None. And Windows Position To Center.

  4. Now take PictureBox and drag it into Form.

  5. Select a picture for this box and dock it with the window, select AnImage for background.

  6. Take 3 Timer Controls from Components Control and drag and drop it into the form.

  7. By double clicking on timer control, add 3 event handlers in your form1 code section.

Using the Code

Now write code as follows:

//

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;
using TailorInventoryAndPos.Properties;
using Timer = System.Threading.Timer;

namespace TailorInventoryAndPos.UI
{
    public partial class StartPage : Form
    {
        private int count = 0, buffer = 0;
        public StartPage()
        {
            InitializeComponent();
            Opacity = 0;
            timer1.Start();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (Opacity == 1)
            {
                timer2.Start();
                timer1.Stop();
            }
            else
            {
                count++;
                Opacity = count*.05;
            }
        }

        private void timer2_Tick(object sender, EventArgs e)
        {
            if (buffer == 3)
            {
                timer3.Start();
                timer2.Stop();
            }
            else
            {
                buffer++;
            }
        }

        private void timer3_Tick(object sender, EventArgs e)
        {
            if (Opacity == 0)
            {
              << Load your another from >>//Optional if you want to load other form
               // this.Hide(); // for loading other form
                timer3.Stop();

                 Application.Exit();
            }
            else
            {
                count--;
                Opacity = count * .05;
            }
        }
    }
}
//

Now build and run your program and watch the magic.

Points of Interest

You can make your own Splash Screen by using this simple method. Feel free to ask any questions.