Adding a Splash Screen to Your Applications

Environment: VC6, Win32

Introduction

Seemingly, every application I create has some lengthy processing in the WM_CREATE section of code. Sometimes, this delay before my main window is displayed causes users to click again on the application icon, thus starting yet another instance of the application. This SPLASH C++ class allows me to easily display a startup splash screen or other information before the main application window is displayed.

Before developing this class, I had tried to use Dialog boxes and timers to simulate a splash screen with limited success. But that method always had less than acceptable results. This class uses a bitmap created in your resource editor and its Resource ID to define the splash screen.

This code uses the bare Win32 API. MFC is NOT REQUIRED!

Using the SPLASH Class

The first thing to do is create the splash screen bitmap. This can be done externally, and then imported into your resource editor, or created within the editor. The resource editor will assign it an ID such as IDB_BITMAP1. This bitmap can be any size. The splash screen window will size to fit it automatically.

In your C++ code, include the SPLASH.H header file; then, create a splash class instance as follows:

  #include "splash.h"
  //global variables
  SPLASH mysplash;

Of course, you'll also have to include your project SPLASH.CPP. Alternatively, you can compile SPLASH.CPP and SPLASH.H to a LIB file and include that in your project.

In your WM_CREATE section of your WndProc, initialize the splash screen with the SPLASH::Init() method as follows:

  mysplash.Init(hWnd,hInst,IDB_BIMAP1);

The Init() method takes a window handle of the parent window of the splash screen, in this case hWnd. The second parameter is the instance handle of the parent Window. Of course, the third parameter is the resource ID of the splash screen bitmap.

After initializing the splash screen, two other methods are used to show or hide the splash screen, Those methods are coincidently Hide() and Show(); both take no parameters.

To display the splash screen, you would do this:

   mysplash.Show();

To hide the splash screen, oddly enough, you would do this:

   mysplash.Hide();

One member variable, (BOOL) SHOWING, is used to programmatically determine whether the splash screen is currently displayed. This allows you to set a timer and hide the splash screen after a predetermined length of time, or hide it upon a mouse click or any other window event.

Example code for this is as follows:

        case WM_LBUTTONDOWN:
            if(mysplash.SHOWING)
                {
                 mysplash.Hide();
                }
            break;

The code below shows the SPLASH class being used in an application.

  #include "splash.h"
  //global variables
  SPLASH mysplash;
   .
   .
   .
  WndProc(...)
   .
   .
   .
        case WM_LBUTTONDOWN:
            if(mysplash.SHOWING)
                {
                 mysplash.Hide();
                }
            break;
        case WM_CREATE:
             mysplash.Init(hWnd,hInst,IDB_BITMAP1);
             mysplash.Show();
             //simulate lengthy window initialization
             Sleep(4000);
             //hide the splash screen as the main window appears
             mysplash.Hide();
            break;

I hope you find this class useful in your application development. I would appreciable feedback via e-mail or the comments section of this article.

Downloads

Download source - 2 Kb


Comments

  • the with greatest satisfaction consequence you can wriggle the clarisonic classic

    Posted by iouwanzi on 06/06/2013 12:57pm

    [url=http://www.australiaclarisonic.com/clarisonic-pro]clarisonic pro[/url] Boucles tombantes ou même les cheveux, le chanteur révélé comme étant une femme fatale dans nuits ainsi que la durée de la nuit ! Je suis un nouvel admirateur concernant les photos noir et blancs ainsi que très certainement l’obscurité des jeux parfois observées.Donc, quand je trouve ce genre d’événement promotionnel préférence efficace et puis j’aime surtout toutes ces se sent compliquée plus élégant ! Et Hanaa Ben Abdesslem voyant qu’il y a toujours dans quelle Katy apporte également les tampons en caoutchouc néanmoins sur une tenue de temps assez longue journée ! [url=http://www.miaclarisonicaustralia.org/clarisonic-pro]clarisonic pro[/url] modestes caractéristiques consistent non pas un mais deux défini guides mise en page talents Deco, simultanément disponible ce sont unique. Toute la galerie Scarlet comprend un sac soie cramoisi tolérant à chaleur merveilleuse lesoù aider à stocker le fer à lisser vos plaques ghd IV Styler cheveux pour s’assurer vous rose profond, par le biais de non pas un mais deux trucs cheveux sauvages dont une instance appropriée.Écrit à l’intérieur d’une boîte commune inflammed inanité habilitée par période de Style déco, tous le groupe écarlate fantaisie ghd styler intemporelle métal jaune comprend une alimentation réduite option rouge et en outre une mallette de rangement, un voyage fabuleux crinière sèche-cheveux ghd, couple de crinière de films et en outre un important carton satiné résistant à la chaleur. [url=http://www.miaclarisonicaustralia.org/]clarisonic australia[/url] Ce redressement en termes de fer relèvent de 4 modèles. Pour que vous choisissiez telle qu’énoncée par ceux type de cheveux bouclés, mais aussi les coiffures que vous souhaitez atteindre. Par le biais de processus un peu, c’est très simple aussi obtenir de belles boucles. Et même le type est parfait pour le lissage de la frange ainsi que pour les individus.Espagne, GHD annonce une promotion très utile. Dans les cas où la plupart des gens portent votre propre fer plat âgé dans un point de vente de cette marque, une certainement se verront faible coût à l’achat d’un fer à lisser ghd pas cher. Il est généralement valable jusqu’au 6 mai 2011. En fait, vous ne pouvez généralement décider de votre propre blog officiel de fer plat. Certaines personnes offrent le monde entier !Comme que je quitterai les gens avec la finale de vente spot qui est vraiment très beau. Une Cendrillon moderne important !

    Reply
  • vi lever i en meget hurtig udvikling æra, necesido én Headphone

    Posted by wanzixiao on 06/04/2013 10:00am

    [url=http://www.beatsbydrdredanmark.blinkweb.com/]beats by dre danmark[/url] Dr. Dre Beats by Dre hovedtelefoner tendens til at være så dygtige i mange hovedtelefoner producerer. Blandt det store udvalg af Monster Beatshovedtelefoner med næsten alle håndsæt kan individuelt kunne være Fahion trend med blanding, med fremragende fordele. De behøver ikke nødvendigvis giver et individ af Dr. Dre hovedtelefoner som de to sider. [url=http://www.beatsbydrdredanmark.blinkweb.com/]beats by dre danmark[/url] Kontakt de mennesker, der får dine ting og give dem konstruktiv klage omkring de spor, de gør. Dette vil få dig beundring, midler og en fremragende popularitet.Overlook sandheden om at skabe tiltalende ord, udvikle vidunderlige spor, samt at blande spor, så de virkelig blande o ‘så perfekt sammen for at hjælpe dig alligevel mærke til de forskellige aspekter af denne blanding. [url=http://www.beatsbydrdredanmark.blinkweb.com/]monster beats danmark[/url] DRE beat, begrebet glatte jazz, klassiske elementer blandet rock, elektronisk musik, skaber fantastiske beats by dre unik lyd. Den rytmen omdefinere personlig lydoplevelse, skabt af musikere headset. Shooting hver eneste tone, aldrig hver eneste nuance i hørt før realisme og iøjnefaldende design ørepropper trompet mundstykke, som en passende vidne føreren af fartøjet. Det er ikke kun de bedste hovedtelefoner til jazz. Uanset om du lytter, vil rytmen være et nyt højdepunkt for al din musik.

    Reply
  • Det er helt naturligt at man spørger sig

    Posted by cheneason on 05/30/2013 07:01pm

    [url=http://www.comprar-auriculares-beats.blogspot.com/]comprar auriculares beats[/url] Ghd sammenlignet med tidligere produkter, denne generation af glat hår med ekstra slankt design, mode af den ydre uanstændige og nogle geniale nye unikke sted i glat hår, hårpleje og styling har gjort store forbedringer. GHD IV styler primære unikt sted: mere vækst i den keramiske varme plader. MK4 Ghd Opvarmningen er færdig vil der være et bip for at gøre dig opmærksom på at organisere ansøgning. Unik og holdbart cover design, ikke noget på egen hånd efter 15 minutter lukkede specielle kabler designet til at opretholde den fugtige keramiske feber tabletter fra skade på miljøet. [url=http://www.cascosbeats.blinkweb.com/]cascos beats[/url] Men det er vigtigt at notere sig at varmepladerne inden i dit ghd glattejern er samme størrelse som de keramiske plader udvendigt. Så jo større glattejern, jo større varmeplader. Dette har man gjort for at sikre sig at alle ghd glattejern har den helt rigtige og helt jævne fordeling af varmen. På den måde sikre ghd sig nemlig at deres glattejern glatter dit hår ordentligt første gang og glatter det hår du arbejder med helt lige og jævnt. [url=http://www.beatsbydreespana.webgarden.com/]beats by dre españa[/url] Din særskilt web-site kan være din person i den vigtigste form for bare at leve netto web-sites inden for de britiske øer denne særlige tilbyder en utrolig mængde af krøllet hår behandling metode variabler ved hjælp af en række forskellige producenter. Disse former for god hår dag krøllet hår produkter igennem flere situationer tilbydes i form af faldende gebyrer. Denne unikke God hår dag Power Suppressor er normalt normalt en stærk tilstrækkeligt godkendt vilde hår terapi om at samle meget følsom med hinanden med sårede Lokker.

    Reply
  • WndProc

    Posted by richiebabes on 11/28/2005 01:49pm

    There is no explanation as to how to use the WndProc thingie.

    Reply
  • Very Good

    Posted by Legacy on 11/05/2003 12:00am

    Originally posted by: Paul

    Simple and elegant. Just what I was looking for. I also #included "stdafx.h" in splash.cpp, and away I went...

    Reply
  • Exactly what I needed

    Posted by Legacy on 04/24/2003 12:00am

    Originally posted by: Vladimir Chesnokov

    Thank you very much!

    To all that call this sample useless: you're so stupid, it should hurt.

    Reply
  • Useless

    Posted by Legacy on 03/05/2003 12:00am

    Originally posted by: Lax

    Hi, this is worthless. Better way is to create a window (WS_POPUP style) in an own thread, it does not affect your program loading time. Create when starting loading and end thread when application has loaded. Thats it.

    Reply
  • Just the 1000th version "Hello, World"

    Posted by Legacy on 01/27/2003 12:00am

    Originally posted by: Someguy

    Isn't it?

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • On-demand Event Event Date: September 10, 2014 Modern mobile applications connect systems-of-engagement (mobile apps) with systems-of-record (traditional IT) to deliver new and innovative business value. But the lifecycle for development of mobile apps is also new and different. Emerging trends in mobile development call for faster delivery of incremental features, coupled with feedback from the users of the app "in the wild." This loop of continuous delivery and continuous feedback is how the best mobile …

  • QA teams don't have time to test everything yet they can't afford to ship buggy code. Learn how Coverity can help organizations shrink their testing cycles and reduce regression risk by focusing their manual and automated testing based on the impact of change.

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds