RSS

C# Splash Screen

22 Mar

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.

Download C# Splash Screen Source Code

Referenced by: http://www.vcskicks.com/splash-screen.php

Advertisements
 
1 Comment

Posted by on March 22, 2011 in C#, Window Application

 

One response to “C# Splash Screen

  1. Fara

    March 25, 2011 at 6:53 PM

    Your idea is outstanding; the issue is something that not enough people are speaking intelligently about. I am very happy that I stumbled across this in my search for something relating to this.Actually, hope you will visit my blog

     

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: