Article ID: 190684 - Last Review: September 30, 2005 - Revision: 4.0

How to add a splash screen to an MFC dialog-based application in Visual C++

This article was previously published under Q190684
Expand all | Collapse all

SUMMARY

The Visual C++ 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. In addition, the documentation for the splash screen component is contradictory and confusing concerning its use in dialog-based applications. This article shows the steps to add a splash screen to an MFC dialog-based application.

MORE INFORMATION

When trying to insert a splash screen into a dialog-based application using the component gallery, you may get an error message that says a mainframe class can not be found. The splash screen component was written to work only in MFC SDI and MDI applications. However, the component code can be used in a dialog-based application by following a few steps:
  1. Build a default SDI application with AppWizard. (This step is necessary just to get the component code inserted in step 2.)
  2. On the VC++ 5.0 Project menu, click "Add to Project," click "Components and Controls...", then double-click "Developer Studio Components." Highlight the "Splash screen" component, and click Insert.
  3. Build a dialog-based application with AppWizard.
  4. Take the two files (Splash.cpp, and Splash.h) produced in step 1, and add them to the dialog-based application's project (step 2).
  5. Override the PreTranslateMessage() for the dialog class. One can do this by opening up ClassWizard and choosing PreTranslateMessage() from the Messages list box. Add the following two lines at the top of the function:
          if (CSplashWnd::PreTranslateAppMessage(pMsg))
               return TRUE;
    					
  6. Add the following two lines to the dialog class's OnInitDialog():
          CSplashWnd::EnableSplashScreen(TRUE);
          CSplashWnd::ShowSplashScreen(this);
    					
  7. Add the following line to the top of the dialog class' implementation file:
          #include "splash.h"
    					
  8. Create a bitmap resource for the splash screen with the ID of IDB_SPLASH.

REFERENCES

For more information, click the following article number to view the article in the Microsoft Knowledge Base:
172336  (http://support.microsoft.com/kb/172336/ ) An assertion is hit in the Afxwin2.inl file when you try to launch an MFC MDI application through a document

APPLIES TO
  • The Component Gallery, when used with:
    • Microsoft Visual C++ 5.0 Enterprise Edition
    • Microsoft Visual C++ 5.0 Professional Edition
    • Microsoft Visual C++ 6.0 Enterprise Edition
    • Microsoft Visual C++ 6.0 Professional Edition
    • Microsoft Visual C++ 6.0 Standard Edition
Keywords: 
kbhowto kbinfo kbwizard kbdlg KB190684
 

Article Translations