
Professional 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 C# applications can have very simple 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...
The most important API function 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 DeleteObjectThe declarations are all included in the API class in the source code.
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 applicaiton.
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...