Welcome Guest!
Create Account | Login
Locator+ Code:

Search:
FTPOnline Channels Conferences Resources Hot Topics Partner Sites Magazines About FTP RSS 2.0 Feed

Free Trial Issue of Visual Studio Magazine

email article
printer friendly
get the code
more resources

Display a WinForms Splash Screen
by Juval Löwy

April 2003 Issue

Technology Toolbox: C#

Figure 1. Create a Splash Screen.

Q: Display a WinForms Splash Screen
My application takes a while to start up. I want to display a splash screen (as Visual Studio .NET and Office applications do) while the application continues loading in the background. The toolbox has no such control. How do I implement it?

A:
The code accompanying this column contains the SplashScreen class:

public class SplashScreen
{
   public SplashScreen(Bitmap splash);
   public void Close();
}

SplashScreen's constructor accepts the bitmap to display. The Close method closes the splash screen. You typically use SplashScreen in the method that handles your form's Load event (see the resulting splash screen in Figure 1):

private void OnLoad(object 
   sender,EventArgs e)
{
   Bitmap splashImage;
   splashImage = new 
      Bitmap("Splash.bmp");

   SplashScreen splashScreen;
   splashScreen = new 
      SplashScreen(splashImage);

   //Do some lengthy operations, then: 
   splashScreen.Close();
   Activate();
}

After you close the splash screen, you activate your form in order to bring it to the foreground and give it focus.

Back to top














Java Pro | Visual Studio Magazine | Windows Server System Magazine
.NET Magazine | Enterprise Architect | XML & Web Services Magazine
VSLive! | Thunder Lizard Events | Discussions | Newsletters | FTP Home