Just to share what i had just learn and hope this can be helpful to the rest
Happy Programming! :)
How to Create a Splash Screen?
Part 1 : Preparing your Screen Splash
Firstly let's start a new C# Window Form Project.
Once this is done, add a new Window Form into the Project and rename it as SplashForm.cs
This new Window Form will be your Splash Screen Window Form.
Ok time to set some properties.
Here are some basic properties you will need to edit :
From the SplashForm.cs Properties,
1. Set the StartPosition to CenterScreen,
2. Set the FormBorderStyle to None, and
3. Change the BackgroundImage to your Splash Screen image.
Now add a timer from the Toolbox,
under the timer Properties,
1. Set the Enabled to True, and
2. Set the Interval to 10000, to indicate how long in milliseconds will the Splash Screen be displayed.
3. Set the Modifers to Public
Now you have done preparing your new Splash Screen, but wait!
So how to display it before the main program start?
Part 2 : Coding your Splash Screen
Now we will need to add some code to the default code in Form1.Designer.cs.
Open your Form1.Designer.cs and code the following code below in InitializeComponent() Method
this.Load += new System.EventHandler(this.SplashScreen_Load);
This statement is to load the SplashScreen_Load Method.
Add a new Method
private void SplashScreen_Load(object sender, System.EventArgs e)
{
frmSplash.ShowDialog();
this.Show();
}
This method will display the Splash Screen First , then show the Main Form.
Declare a new assignment
public SplashForm frmSplash = new SplashForm();
This declaration is to assign frmSplash
Not over as yet!
Now we have done with how to display the Splash Screen
Part 3 : Closing a Splash Screen
we will now proceed to code how to close the Splash Screen
Now we will need to add some code to the default code in SplashForm.Designer.cs.
Add the following code into InitializeComponent() Method
this.Click += new System.EventHandler(this.SplashForm_Click);
and add 2 new methods
public void SplashForm_Click(object sender, System.EventArgs e)
{
this.close
}
public void timer1_Tick(object sender, System.EventArgs e)
{
this.close
}
So to close the Splash Screen, the two condition stated in the method will be either by mouse click on the Splash Screen Window or when the timer goes from 10000 to 0
Now you have finally created and coded your splash screen.
Press F5 and see if it works.
Hope this is proven helpful to all.
PS: This is my first guide so go easy on me :p
If there is any incorrect information please comment and i will get them corrected. Thank!
Changes Log:
1. Correction from second to milliseconds for Interval Setting for timer
2. Include a setting requirement for timer to work, setting Modifers from private to public
Edited by diz, 08 June 2009 - 07:34 PM.


Sign In
Create Account

Back to top









