Click here to Skip to main content
Licence 
First Posted 15 Dec 1999
Views 177,483
Downloads 5,488
Bookmarked 84 times

Adding a splash screen to your dialog based application

By Kirk Stowell | 8 Aug 2002
Splash screens are not only for Doc/View based applications
1 vote, 4.5%
1

2

3
8 votes, 36.4%
4
13 votes, 59.1%
5
4.57/5 - 55 votes
1 removed
μ 3.82, σa 1.60 [?]
This article including source code copyright © 2001 Codejock Software, All Rights Reserved.  Feel free to use any of the source code found in this article without restriction.

Introduction

If you have ever created a dialog application, and then tried to add a splash screen using the splash screen component, you may have found out that it won't allow you to.  This article is a quick tip for adding a splash to your dialog application using the CSplashWnd class.  This class is an enhanced version of the one that is normally generated by the splash component for a document view project.

In order to use the CSplashWnd in our dialog based application, we will have to override three functions, CDialog::OnInitDialog(), CWinApp::InitInstance() and CWinApp::PreTranslateMessage(MSG* pMsg)OnInitDialog and InitInstance should have already been added to your project when you created it if you used the AppWizard, however you may have to add PreTranslateMessage to your CWinApp derived class.

Step 1:

Add the following line of code to your CDialog::OnInitDialog method just before it looses scope.  The first argument to ShowSplashScreen is the time out value in milliseconds, this is how long the splash screen will be displayed before it closes.  The second argument is the resource identifier of the bitmap image that we will be using as the splash screen. The last argument is the parent window, this parameter can be NULL.

// Create and show the splash screen.
CSplashWnd::ShowSplashScreen(3000, IDB_SPLASH24, this);

Step 2:

Add the following line of code, toward the very beginning of the CWinApp::InitInstance, just after the call ParseCommandLine(...).  You will need to add ParseCommandLine if it is not already included.

// Enable the splash screen component based on the command line info.
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);

CSplashWnd::EnableSplashScreen(cmdInfo.m_bShowSplash);

Step 3:
Use Class Wizard to override CWinApp::PreTranslateMessage(MSG* pMsg), and add the following lines of code:

BOOL CMyApp::PreTranslateMessage(MSG* pMsg) 
{
    // Route messages to the splash screen while it is visible
    if (CSplashWnd::PreTranslateAppMessage(pMsg)) {
        return TRUE;
    }
    
    return CWinApp::PreTranslateMessage(pMsg);
}

History

9 Aug 2002 - rewritten extensively.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Kirk Stowell

CEO
Codejock Software
United States United States

Member


Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Generaldynamic splash screen Pinmembershital_harode@rediffmail.com1:40 2 Nov '06  
GeneralEmbedded JPG || GIF PinmemberArvinB10:16 19 Oct '06  
GeneralRe: Embedded JPG || GIF Pinmembergopalcdas0:17 25 Sep '08  
QuestionCopyrighted ? Pinmembertoxcct7:10 30 Jun '05  
AnswerRe: Copyrighted ? PinsupporterDavid Wulff7:40 30 Jun '05  
GeneralGet SplashScreen to Close Programatticaly PinmemberRichard Males14:17 3 Oct '04  
GeneralRe: Get SplashScreen to Close Programatticaly PinmemberRWThompson10:36 24 Oct '04  
QuestionShowing Splash before creating CMainframe? PinmemberMiguel Lopes4:02 25 Feb '04  
Generaldynamic splash screen PinmemberCorey W16:53 16 Jan '04  
GeneralRe: dynamic splash screen PinmemberCokeisit3:08 21 Apr '04  
GeneralRe: dynamic splash screen Pinmembertemich22:39 20 Jun '04  
GeneralRe: dynamic splash screen PinmemberCokeisit6:42 3 Jul '04  
GeneralPrevent mouse clicks PinmemberCokeisit4:19 16 Dec '03  
GeneralModifications Pinmembermatty1595:20 20 Mar '03  
GeneralRe: Modifications PinmemberCokeisit4:14 16 Dec '03  
GeneralRe: Modifications Pinmembervijayvinoth3:05 19 Sep '10  
Generalvery nice Pinmemberarnaba10:13 19 Jan '03  
GeneralCool! PinmemberSelevercin15:05 14 Dec '02  
Generalchange sample file PinmemberMazdak3:29 20 Aug '02  
GeneralUnflappability PinsussAnonymous19:29 10 Aug '02  
GeneralRe: Unflappability PinmemberRashid Thadha2:51 11 Aug '02  
GeneralKirk don't let these losers get at you PinmemberNorm Almond9:02 10 Aug '02  
GeneralRe: Kirk don't let these losers get at you PinmemberMichael A. Barnhart17:42 10 Aug '02  
GeneralPoor!! This is not English! Pinmembersupertedusa4:42 24 Jun '02  
GeneralFIX: splash wnd closed on mouse click PinmemberAnonymous0:15 18 Mar '02  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    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 | Mobile
Web03 | 2.5.120210.1 | Last Updated 9 Aug 2002
Article Copyright 1999 by Kirk Stowell
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid