Click here to Skip to main content
13,142,065 members (54,468 online)
Click here to Skip to main content
Add your own
alternative version


51 bookmarked
Posted 21 Apr 2009

Splash Screen C++ Class without MFC or .NET

, 21 Apr 2009
Rate this:
Please Sign up or sign in to vote.
A C++ class to generate a splash screen and about box from a bitmap and version string resources.


Every application needs an “about box” and some need a “splash screen” while loading. Most developers use the boring “about dialog” that is created automatically. I created the class, CSplashScreen, to handle both, to make them less error prone and to make them more interesting. I use this class for programs from tiny dialog applets to complex applications that take a couple of minutes to load and initialize.

The class consists of two files, SplashScreen.h and SplashScreen.cpp. The class does not require MFC or .NET. I have another class that uses MFC.

The class gets all the information to display the splash screen from a bitmap and the version strings in the resources. Therefore, you don’t have to modify the splash screen every time the version changes.

The splash screen disappears when clicked on, a key is pressed, or the desired time has elapsed.

Splash Screen Example

Using the code

  • Include SplashScreen.h and SplashScreen.cpp.
  • Add version strings to the resources.
  • Add the IDB_SPLASH bitmap to the resources.
  • Add version.lib to the link libraries.

ShowSplashScreen(HWND pParentWnd, LPCTSTR statusMessage, int millisecondsToDisplay) can have zero to three parameters.

  • pParentWnd - parent window of splash screen
  • statusMessage - string to display in status area of splash screen
  • millisecondsToDisplay - number of milliseconds before hiding splash screen

To show the splash screen during initialization, add CSplashScreen::ShowSplashScreen();.

#include "SplashScreen.h"

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
    MSG msg;
    // display splash screen and have it turn off after 10 seconds
    CSplashScreen::ShowSplashScreen( hWnd, "", 10000);
    while (GetMessage(&msg, NULL, 0, 0))  {
        if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) {

    return msg.wParam;

To show the about box, add CSplashScreen::ShowSplashScreen() to WndProc(…):

#include "SplashScreen.h"

    switch (message) {
    case WM_COMMAND:
        // Parse the menu selections:
        switch (LOWORD(wParam)) {
        case IDM_ABOUT:
            // display about box
            CSplashScreen::ShowSplashScreen( hWnd );
        return DefWindowProc(hWnd, message, wParam, lParam);
    return 0;

Under the hood

Since I’m a consultant, I create a specialized bitmap for each client. I typically place the company logo and the application icon in the IDB_SPLASH bitmap. Depending on your artistic talent, you can make a very professional splash screen. The version strings are written on top of the bitmap.

There are 3 groupings of strings: Product Name, Body, and Status. The Body consists of one or more of the company name, version, copyright, and comment strings. I prefer the product name to be larger, with the multiple lines of the body smaller. I use Status only when the application is loading.

Each group has static variables that specify how the strings in that group are drawn:

  • m_xxxVerticalOffset - empty space between the top of the bitmap and the first string
  • m_xxxVerticalHeight - the maximum height of a group of strings
  • m_xxxLeftMargin - the distance from the left side to the place strings
  • m_xxxRightMargin - the distance from the right side to strings
  • m_xxxFontName - the name of the font for strings
  • m_xxxPointSize - the point size used for strings, (-1,-1) ==> Calculate point size
  • m_xxxTextColor - the color used for strings

The body can have from 0 to 4 strings. Set the static display variables:

  • m_displayCompanyName - true if displaying company name
  • m_displayVersion - true if displaying version
  • m_displayCopyright - true if displaying copyright
  • m_displayComments - true if displaying comments

The CSplashScreen class is instantiated when CSplashScreen::ShowSplashScreen() is called. It is deleted when the timeout elapses, a key is pressed, or the the mouse is clicked.


  • Date posted: April 21, 2009


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Chris Apple
Software Developer (Senior) Apple Enterprises -
United States United States
I have been a software consultant at Apple Enterprises,, since 1981, a paid programmer since 1975 and a programmer since 1969 when I took my first programming class at U.C. Berkeley. I graduated with an EECS degree in 1975 after a 2 year hiatus in the US Marine Corps as a infantry machine gunner.

I started working when the original Intel 8080 microprocessor was announced. My first product was a wire bonder that had four 8080 microprocessors controlling high speed motors. Lately I have been using the TI MSP430, NXP LPC2300 and the Renesas SH4 microcontrollers.

I write code in assembly, C, C++ and Java and occasionally design a board when needed. Most of the time the code is system level, low level and drivers, but I do write applications. Most embedded devices usually have a PC controller application that I write. The code is used in Windows, Windows CE and proprietary operating systems. I use Visual Studio 2008, IAR and Keil IDEs. I even create single click installations, especially complex ones that require third party installs.

I have developed over 50 products.

I host the UC Berkeley Engineering Alumni Society (South Bay):

I live in Silicon Valley, play full court basketball once a week, work out at the gym during the week and hike with my wife on the weekend.

You may also be interested in...

Comments and Discussions

PraiseStill works, nice Pin
rvangaal29-Jan-17 4:00
memberrvangaal29-Jan-17 4:00 
BugVery nice!!! Does leak memory though... Pin
AlhajiBello29-Sep-12 11:11
memberAlhajiBello29-Sep-12 11:11 
BugSome bug Pin
Alexey Voropaev11-May-12 2:53
memberAlexey Voropaev11-May-12 2:53 
QuestionLoad time Pin
Chris Millward10-Mar-12 7:36
memberChris Millward10-Mar-12 7:36 
AnswerRe: Load time Pin
Chris Apple10-Mar-12 8:39
memberChris Apple10-Mar-12 8:39 
GeneralGetVersionStrings() fails Pin
megraham@msn.com19-May-09 10:19
membermegraham@msn.com19-May-09 10:19 
GeneralRe: GetVersionStrings() fails Pin
alexey.voropaev11-May-12 2:42
memberalexey.voropaev11-May-12 2:42 
GeneralRe: GetVersionStrings() fails Pin
Chris Apple11-May-12 4:55
memberChris Apple11-May-12 4:55 
GeneralVery nice! Pin
Hans Dietrich22-Apr-09 0:36
mvpHans Dietrich22-Apr-09 0:36 
GeneralRe: Very nice! Pin
Chris Apple22-Apr-09 3:43
memberChris Apple22-Apr-09 3:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170915.1 | Last Updated 21 Apr 2009
Article Copyright 2009 by Chris Apple
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid