Splash Screen

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

Howdy folks,


How would one go about making a splash screen (message appearing while main
program loading) in c#


cheers in advanced



Steve
 
In your main form constructor, hide the main form.
Create your splash screen form instance and show it with Form.Show()
(not ShowDialog)
Continue with your initialisation code.
When your code is complete, close the splash screen with Form.Close()
and probably dispose it as well.
Show the main form again with this.Show()

You could also do it in the main static method. Show slash form,
initialise, show main form.

Thats the theory anyway!

Steven Nagy
 
Here's an example. The splash form is made transparent with a bee, so
when it loads, only the bee is visible. Then a timer, in frmSplash,
will close the form after 1375 ms. The bee will "fly" away to the upper
left corner and finally disappear.

However, is there a better way to animate the bee than my example?

The code in frmSplash:

private void timer1_Tick(object sender, System.EventArgs e)
{
this.Left = 400;
this.Top = 300;
this.Left = 375;
this.Top = 275;
this.Left = 350;
this.Top = 225;
this.Left = 300;
this.Top = 200;
this.Left = 250;
this.Top = 150;
this.Left = 200;
this.Top = 100;
this.Left = 100;
this.Top = 75;
this.Left = 50;
this.Top = 10;
this.Left = 0;
this.Top = 0;
Close();
}

private void frmSplash_Load(object sender, System.EventArgs e)
{
timer1.Enabled = true;
}

And in frmMain:

[STAThread]
static void Main()
{
///start splash-form for application
Application.Run(new frmSplash());

///start main-form
Application.Run(new frmMain());
}

Me.Name
 
Hi,

If you google you will find several examples of a splash screen , this
question is posted here on a regular basis
 
Hi,
[STAThread]
static void Main()
{
///start splash-form for application
Application.Run(new frmSplash());

///start main-form
Application.Run(new frmMain());
}

What happens if frmMain loads before the timeout? , how does it close the
splash?
 
Back
Top