C# School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a C# Expert!

Join 300,440 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 1,503 people online right now. Registration is fast and FREE... Join Now!




How to Make a Splash screen

 
Reply to this topicStart new topic

> How to Make a Splash screen

X@MPP
Group Icon



post 14 Mar, 2009 - 02:20 PM
Post #1


OK, this is my tutorial on how to make a simple splash screen for a Windows Form application.

First, start by opening Visual Studio 2008 or C# Express 2008 and create a new Windows Form App Project in C#. You can call it whatever you'd like; I just used SplashScreen.

Now add a new Windows Form named SplashScreen to this project.

You should now have 2 forms; the automatically-created main form, which by default should be called Form1, and another form called SplashScreen. In the designer, click on your new form. You should be able to see the Properties Window (usually in the lower right corner of the IDE). In that window find the following properties and set them:

ControlBox to False
FormBorderStyle to None

The rest of the properties should look like this:

Attached Image

The form in the designer should now be nothing but a plain box.

Customize the Splash screen to your liking and add a timer by dragging a Timer from the Toolbox's Component section and dropping it on the SplashScreen form. This should add a timer object, named timer1, to the form and open up the Timer's Properties Window in the IDE. Set the timer's Enabled property to True and the Interval setting to however long you'd like your splash screen to stay open (the unit of measure is milliseconds, so choose the number of seconds you'd like and multiply by 1000). I use 1000 to 3000 for the value.

Next we need to add the Tick event, which is the event that is raised when the timer's interval has elapsed. The easiest way to do this is to click the little lightning bolt icon in the timer's Properties box, which brings up the events that are exposed by the timer object. Double-click in the empty box next to Tick to add the event to the SplashScreen class and load the empty event handler code in the IDE's main window. As a splash screen, the only thing we want to happen when the timer expires is to close ourselves, so add this.Close(); to the generated timer1_Tick() method:

csharp
private void timer1_Tick(object sender, EventArgs e)
{
// Close the splashscreen
this.Close();
}


Finally, we need to integrate the SplashScreen class into our application. We will do this by adding code to the main form's Load event to create the SplashScreen class and show the window.

First bring up the main form GUI in the IDE's main window and click it to show the form's Properties box. We need to add our code to the form's Load event, so again click on the lightning bolt to bring up the available events for the main form and find the Load event. Double-click on the empty box next to the Load event to create (or edit, if it already exists) the Form1_Load() event handler. Add the following code to the event handler:

csharp
private void Form1_Load(object sender, EventArgs e)
{
SplashScreen Splash = new SplashScreen();
Splash.Show();
}


Go back to the Properties of Form1 and change the StartPosition property to CenterScreen so that the splash screen will cover it.

That's it!
Go to the top of the page
+Quote Post


Register to Make This Ad Go Away!

zahur
*



post 2 May, 2009 - 09:22 AM
Post #2
Thanks alot for the contribution...
Go to the top of the page
+Quote Post

X@MPP
Group Icon



post 2 May, 2009 - 11:44 AM
Post #3
QUOTE(zahur @ 2 May, 2009 - 09:22 AM) *

Thanks alot for the contribution...

thanx
Go to the top of the page
+Quote Post

dExIT
*



post 16 May, 2009 - 10:11 AM
Post #4
i red the whole thing, but i cant still seem to understand, how can i make the splashScreen a .gif ( i have the GIf and its Transparent ) ?
Go to the top of the page
+Quote Post

ddrose
*



post 17 Jun, 2009 - 08:56 AM
Post #5
Thank You!!! Simple and effective icon_up.gif
Go to the top of the page
+Quote Post

praneeshpeeyar
*



post 17 Jun, 2009 - 09:38 AM
Post #6
thanks.... Good One....!
Go to the top of the page
+Quote Post

geekhelp
*



post 12 Jul, 2009 - 05:20 PM
Post #7
QUOTE(dExIT @ 16 May, 2009 - 10:11 AM) *

i red the whole thing, but i cant still seem to understand, how can i make the splashScreen a .gif ( i have the GIf and its Transparent ) ?



In the new windows form, make a new picture box, put your picture in, and resize to your liking.
Go to the top of the page
+Quote Post

carck3r
*



post 26 Jul, 2009 - 07:55 AM
Post #8
CODE
SplashScreen splash = new SplashScreen();
            splash.Show(); // show
            Thread.Sleep(3000); // sleep main thread for 3 seconds
            splash.Close(); // close splash screen

It's easier way to show splash screen.
Go to the top of the page
+Quote Post

X@MPP
Group Icon



post 26 Jul, 2009 - 12:17 PM
Post #9
QUOTE(carck3r @ 26 Jul, 2009 - 07:55 AM) *

CODE
SplashScreen splash = new SplashScreen();
            splash.Show(); // show
            Thread.Sleep(3000); // sleep main thread for 3 seconds
            splash.Close(); // close splash screen

It's easier way to show splash screen.

ya im working on a lot now but i will make a new tut for an more advanced splash screen
Go to the top of the page
+Quote Post


Fast ReplyReply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 


Lo-Fi Version Time is now: 11/8/09 01:12AM

Live C# Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

C# Tutorials

Reference Sheets

C# Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month