Microsoft KB Archive/190684

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

Article ID: 190684

Article Last Modified on 9/30/2005

-

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</li></ul>

 Microsoft Visual C++ 6.0 Standard Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q190684

<div class="summary_section">

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.

<div class="moreinformation_section">

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: <ol> Build a default SDI application with AppWizard. (This step is necessary just to get the component code inserted in step 2.)</li> 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.</li> Build a dialog-based application with AppWizard.</li> 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).</li>  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; </li>  Add the following two lines to the dialog class's OnInitDialog: CSplashWnd::EnableSplashScreen(TRUE); CSplashWnd::ShowSplashScreen(this); </li>  Add the following line to the top of the dialog class' implementation file: #include "splash.h"                   </li> Create a bitmap resource for the splash screen with the ID of IDB_SPLASH.</li></ol>

<div class="references_section">