Splash Screens and non-rectangular windows

I needed a splash screen for my music player app. I tried a couple of ideas that didn’t
work very well, but then I hit on the idea of using the image
of a CD
as the background of the splash screen – and doing a non-rectangular window.
I’ll start with the splash screen…

Conceptually, a splash screen is pretty simple – it’s just a form that you bring up
at the start of the program. The code is something like this:

SplashForm splashForm;
public MyForm()
    splashForm = new SplashForm();

and we’ll hook the Activated event to hide the form.

private void Form1_Activated(object sender, System.EventArgs e)

When we run this, however, something strange happens. The form comes up, but it never
renders – there’s just a black background. This is because we need the windows messages
to be processed to get the form to paint. There are several ways to do this, but my
choice is to simply call Application.DoEvents() after the form is shown. This processes
any messages that have yet to be processed, showing the form.

Next, we need to make a non-rectangular form. This is done by setting the region on
the form. This is surprisingly easy to do. Here’s the code I used for the CD:

public SplashForm()
    GraphicsPath p = new GraphicsPath();
    p.AddEllipse(2, 4, 340, 341);
    p.AddEllipse(150, 153, 43, 43);
    this.Region = new Region(p);


The first ellipse defines the outside of the picture, and then the second one this
inside. This gives me a round window with a hole in the center.

Pretty cool!

Comments (8)

  1. Jacob says:

    I use a slightly different approach for my splash screens, but I think the end result is the same:

    Public Class ApplicationEntryPoint
    Private Shared m_splash As SplashScreen
    Private Shared m_context As ApplicationContext

    Private Sub New()
    End Sub

    <STAThread()> _
    Public Shared Sub Main(ByVal CmdArgs() As String)
    m_context = New ApplicationContext()
    If CmdArgs.Length > 0 AndAlso CmdArgs(0) = "/NoSplash" Then
    m_context.MainForm = New MainForm()
    AddHandler Application.Idle, AddressOf AppIdle
    m_splash = New SplashScreen()
    m_splash.TopMost = True
    End If
    End Sub

    Private Shared Sub AppIdle(ByVal sender As Object, ByVal e As EventArgs)
    If m_context.MainForm Is Nothing Then
    RemoveHandler Application.Idle, AddressOf AppIdle
    m_context.MainForm = New MainForm()
    m_splash = Nothing
    End If
    End Sub

    End Class

  2. Irfan Patel (MCSD) says:

    Nice code for the non-rectangular way but I created a new class for splash screen and frmMain in C#.

    There is a timer set in frmSplash whose tick event has databaseconnection code and this.Close(); to close the frmSplash

    :) The additional class is as follows

    using System;

    using System.Windows.Forms;

    namespace MyNamespace.Classes


    /// <summary>

    /// Summary description for clsMain.

    /// </summary>

    public class clsMain


    public clsMain()




    static void Main()


    frmSplash objfrmSplash = new frmSplash();


    clsGlobal.g_objfrmMain = new frmMain();






    Have a nice time :)


  3. MBA says:

    Helpful For MBA Fans.

  4. .Avery Blog says:

    Splash Screens in Windows Forms

  5. James Avery makes a point that Eric Gunnerson has a way of doing splash screens. Unfortunately…