windowsforms-10825-controls-and-libraries-forms-and-user-controls-splash-screen-manager-splash-image.md
The Splash Screen Manager allows you to display any image as a splash screen.
The main features include:
This approach allows you to show any image as a splash screen with a single line of code. You can use a custom painter to draw over the splash image (for example, paint a progress indicator).
To invoke a splash image, call the static SplashScreenManager.ShowImage method, specifying the target image as a parameter. To hide the image, call the static SplashScreenManager.HideImage method.
Image im = Image.FromFile("mySplashScreen.png");
SplashScreenManager.ShowImage(im);
//...
SplashScreenManager.HideImage();
Dim im As Image = Image.FromFile("mySplashScreen.png")
SplashScreenManager.ShowImage(im)
'...
SplashScreenManager.HideImage()
The SplashScreenManager.ShowImage method overloads allow you to specify the image position and enable fade animation effects.
To display a splash image and draw graphics over the splash image, do the following:
The ICustomImagePainter.Draw method is invoked each time the image is displayed. To force a splash image to update, call the SplashScreenManager.Invalidate method. See this topic for an example.
This approach provides the following customization options:
Right click the SplashScreenManager component in the Visual Studio tray and select Add Splash Screen.
Double-click the generated SplashScreen1.cs (SplashScreen1.vb) file in the Solution Explorer to open the design-time editor.
Set the SplashScreen‘s ShowMode property to Image.
You can also use the SplashScreen.SplashImageOptions property to specify a custom image.
To display custom controls above the image:
Note
If you need to extend SplashScreen1.cs/.vb files with custom classes, ensure that the class encapsulating your Splash Screen goes first in these files.
To automatically display the created Splash Image on your main form’s startup, ensure the SplashScreenManager’s Active Splash Form is set to your splash screen. Open the SplashScreenManager’s smart tag and check the Active Splash Form setting.
Alternatively, you can check the SplashScreenManager.ActiveSplashFormTypeInfo setting in the Property Grid.
The Splash Screen Manager automatically displays the active Splash Screen on your main form’s startup and closes it when your main form was initialized and displayed.
Ensure that the Splash Screen Manager’s Active Splash Form is set to ‘(None)’.
To display and close the created Splash Screen, use the static SplashScreenManager.ShowForm and SplashScreenManager.CloseForm methods.
SplashScreenManager.ShowForm(typeof(SplashScreen1));
//...
SplashScreenManager.CloseForm();
SplashScreenManager.ShowForm(GetType(SplashScreen1))
'...
SplashScreenManager.CloseForm()
Splash screens are displayed in a separate thread. In code, you can interact with the active Splash Screen (for instance, dynamically update custom controls) via commands sent by the SplashScreenManager.SendCommand method. To process these commands, override the SplashScreen.ProcessCommand method.
See Also
How to: Show an Image as a Splash Screen and Draw Custom Information Over this Image