Splash Screens

G

Guest

Hello all

I would like my Windows Forms C# application to exhibit the following behaviour

1. Display a Splash Screen, topmos
2. Display the main application MDI window behind this. Make sure it is properly visible
3. Load database data, etc. A relatively time consuming task
4. Remove Splash Scree
5. Display a modal Log On dialog over the top of the MDI windo

To me, the best way to do this is to write the code in the Main routine, but I can't get the behaviour I need

Code snippets such as

===============

splashForm = new SplashForm()
splashForm.Show()
splashForm.Refresh()

mainForm = new MainForm()
mainForm.Show()
mainForm.Refresh()

mainForm.LoadSettings()

splashForm.Close(
splashForm.Dispose()

Application.Run(mainForm)

===============

do display the splash form correctly, but of course the main form is not repainted if it happens to become invalidated by another application. Also, this does not do the Log on dialog

The following incomplete code works correctly in VB6

===============

Public Sub Main(

With frmSplas
.ZOrder
.Sho
.Refres
End Wit

Load frmMainParen
frmMainParent.Enabled = Fals

SystemSettingsInitialis

frmSplash.Hid
Unload frmSplas

frmMainParent.Enabled = Tru

Logo

end su

===============

How do I do this in C# please

Many thanks

And
 
C

Clemens Rossell

For my splash screen I did the following in Main:

InstanceChecker myInstance = new InstanceChecker();

if ( !myInstance.isRunning )
{
BHSplash splash = new BHSplash();
BHMain mainApp = new BHMain();

Application.Run( splash );
Application.Run( mainApp );
myInstance.ReleaseMutex();
}

where InstanceChecker is a private class that helps check whether an
instance of the app is already running. BHSplash is my splash form and
BHMain is the main form.

However, this will probably not work for you because as I designed it
the splash form loads, then a timer on the form closes the form, after
which the main form loads (since Application.Run() will not return until
the form closes).

I would suggest that you do something like the following in Main:

if ( !myInstance.isRunning )
{
Application.Run( new MainForm() );
myInstance.ReleaseMutex();
}

and then in the constructor for MainForm you'd have something like:

SplashForm splash = new SplashForm();
splash.TopMost = true;
splash.Show();
//
// do other processing
//
splash.Close();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top