How to Create a Custom Shape Splash Screen in Visual Basic – Visual Studio 2015

Tested in Windows XP,  Windows 7 (all versions) with Visual Studio 2015 as IDE.

There is no straight property setting or configuration option available to create a Splash Screen in Windows Form Applications. Creating a custom screen is a roundabout solution using a form attribute called TransparencyKey.

First you will need the custom shape as a bitmap image with an uniform background to the image as shown. This background will be rendered transparent using the TransparencyKey form attribute and a few lines of code.

The background color should be unique and not match any color in the main image else that portion will also be transparent.

Create a new Windows Forms Application project (or open an existing one) in Visual Studio 2015.

From Project menu Add New Item > Windows Forms > Splash Screen.

Open the Splash Screen in design mode. Select and delete the Application Title panel, do the same for Details Layout Panel which contains version and copyright information. Click on BackgroundImage property of Splash Screen in solution explorer. Clear the background image from Resource Context panel.

Double click on the Splash Screen in design mode or right click on the Splash Screen item in Solution Explorer window and select view code. Inside the Splash Screen load method place the follow code –

 Dim Img As Bitmap = Bitmap.FromFile("C:\\images\butterfly.png")
 Me.BackgroundImage = Img
 Me.BackgroundImageLayout = ImageLayout.Stretch
 Me.TransparencyKey = Img.GetPixel(10, 10)
 Me.FormBorderStyle = FormBorderStyle.None

Here “butterfly.png” is the file from which the splash screen is created. You can use any image you want.

Me.BackgroundImage : this line will set the background image of the Splash Screen to the bitmap created in line 1.

Me.BackgroundImageLayout : this line will stretch the image to cover the whole of Splash Screen. Any other value may generate unexpected results.

Me.TransparencyKey : this line is the key line. This line sets the form TransparencyKey to the pixel color at position 10 x 10 in the image, which in this case is the uniform background color of the whole image. It is a variable and can change from image to image depending on what you want to make transparent. Experiment with different positions.

Next – open Project menu > WindowsApplication1 Properties WindowsApplication1  can be a different name depending on how you named your application ). In the Splash Screen drop-down option at the bottom choose the already created Splash Screen. Click on the View Application Events option just next to this drop-down and insert the following code inside Partial Friend Class MyApplication –

 Protected Overrides Function OnInitialize(commandLineArgs As ReadOnlyCollection(Of String)) As Boolean
  Me.MinimumSplashScreenDisplayTime = 5000
  Return MyBase.OnInitialize(commandLineArgs)
 End Function

Me.MinimumSplashScreenDisplayTime  can be set to any value you want. Typically a value between 3000 ( 3 seconds) and 5000 ( 5 seconds ) is all you need.

Save and compile / run the application. You should get the nice butterfly (or whatever you used) showing up just before your main form loads.