C# Programming > Forms

C# Splash Screen

c# splash screen

Application Splash Screen

Professional .NET software applications very often have a splash screen that appears while an application loads. A splash-screen not only gives the user something to look at while the program loads, but it gives a professional presentation to your C# applications.

While applications can have very simple C# splash screens, in this article let's go over the components of making an advanced splash screen. For shadows and transparency, you'll need a few API calls to enabled transparency in a Window Form background image.

API Calls Required

The most important API function to create our C# splash screen will be UpdateLayeredWindow. UpdateLayerWindow is a very useful function. Not only will it enable our application to display background images with transperancy, that includes shadows, but it will also eliminate the need to manually custom-shape the Windows Form.

However it will not be the only API call, since the splash Form will display an image we need some common API calls to handle images:

GetDC
GetCompatibleDC
ReleaseDC
DeleteDC
SelectObject
DeleteObject
UpdateLayeredWindow
The declarations are all included in the API class in the source code.

Extend Style - Windows Form

There is one final adjustment to set to the Windows Form. The Form style needs to be extended to allow "layers" which the API calls will utilize. To set WS_EX_LAYERED to the splash-screen, you will need to override the CreateParams property:

protected override CreateParams CreateParams
{
     get
     {
         CreateParams cp = base.CreateParams;
         cp.ExStyle |= 0x00080000; // Required: set WS_EX_LAYERED extended style
         return cp;
     }
}

Combined with the API calls, the C# splash screen can now display shadows and even transparent areas like a professional software application. The only drawback is the UpdateLayeredWindow API call (which is the one that renders the image) makes normal controls not appear. There is no way around this, except to draw the image with other methods or move to newer technologies such as WPF.

Download the provided source code to see a working example of the splash-screen and to see the detailed C# function that calls the appropriate API functions.

Back to C# Article List