We help IT Professionals succeed at work.

Splash Screen in Dialog-Based Visual C++ Application

Larry
Larry asked
on
Reference MS Knowledge Base Article ID: Q190684
"HOWTO: Insert a Splash Screen into a Dialog-Based Application"

"The Visual Component Gallery allows one to insert a variety of standard components into applications.  Using the gallery, one can easily insert a splash screen into MFC SDI and MDI applications.  However, the Visual C++ Component Gallery does not allow insertion of a splash screen into a dialog-based application."

The above MS Knowledge Base article explains how to do it but it doesn't work.  The created dialog-based application compiles but does not display the splash screen.  HOW DO I DO IT?
***********************************************************
IF cwrea IS CORRECT, I AM INCORRECTLY COMPLETING STEP 6 OF THE MS KNOWLEDGE BASE INSTRUCTIONS.  WHEN I CHECK EXECUTION IN THE DEBUGGER, CSplashWnd::ShowSplashScreen(this) fails.  I imported a bitmap resource and renamed it IDB_SPLASH as instructed but the application doesn't seem to find it.

TO RECAP:  I AM RUNNING VISUAL C++ 6.0.  THE TEST DIALOG-BASED APPLICATION COMPILES WITHOUT ERROR BUT DOES NOT DISPLAY THE SPLASH WINDOW.  ONLY THE APPLICATION DIALOG BOX WITH CANCEL & OK BUTTONS APPEARS.  ANY CHANCE I COULD GET AN EMAIL COPY OF THE A RUNNING EXAMPLE.  EMAIL:lphull@anteon.com.  Thanks -- Larry
Comment
Watch Question

ekc

Commented:
Create a SDI application and generate splash screen component in it, the way it is normaly done.
Then copy the generated files "splash.h" and "splash.cpp",  to your dialog-based project and do the following modifications to it.

1. Add the

#include "splash.h"

on the tp of your dialog CPP file.

2. Add the following lines of code at the end of your OnInitDialog() function:

     CSplashWnd::EnableSplashScreen(TRUE);
     
     CSplashWnd::ShowSplashScreen(this);

3. Don't forget to add the BMP file (your splash screen visual interpretation) to the project via resource editor. Set its name to IDB_SPLASH (the name generated by wizard. You can change it, but then check this in the splash code)

4. Compile the project and enjoy your new splash. :)
Software Craftsman
Commented:
I tried it with Visual C++ 6 as instructed in the KnowledgeBase article and didn't have any problems.  What version are you using?

I'll assume you followed at least steps #1-#4 correctly.  Here's an analysis of what could go wrong if the other steps weren't followed right:

If you don't follow step #5, the dialog will show but clicking will not make it go away - it must time out instead.

*** If you don't follow step #6 properly, the dialog won't show at all.  Maybe that step was accidentally omitted?

If you don't follow steps #7 or #8 properly, the project simply won't compile.


Another thing to look at... the dialog is by default configured to go away after 750 milliseconds; that is, after only three quarters of a second.  Try increasing the timeout to a few seconds and see if it shows.  You'll find the timeout on line 115 of the generated Splash.cpp in the function CSplashWnd::OnCreate().  Change the 750 to 3000, for example.

Author

Commented:
Thanks for guidance on adding a splash screen to a dialog-based Visual C++ application.  I finally got it running after a complete rebuild.