![]() |
|
QA: How can I show a splash screen during my application startup?
By Daniel Strigl, March 12, 2004.
QuestionI want to show a splash screen during my application startup that hides automatically after a given time or when the user taps with the stylus pen on the screen. How it can be done? AnswerThe easiest way is to create a simple window without boarder and caption that draws the splash image in the OnPaint message. After the window creation start a timer for the time you want to show the splash screen. When the timer run off or the user taps with the stylus pen on the screen destroy the splash screen window.
I have written a simple class, called CSplashWnd, that includes all the necessary stuff for the window creation and the timer setup, so that the usage is very simple. First add the following two files (included in the sample application at the end of this article) to your project:
After that add the following code to your application files: In the application main class, XxxApp.h and XxxApp.cpp: In the frame window class, MainFrm.cpp: The function call CSplashWnd::ShowSplashScreen(IDB_SPLASH, 5000, this); will show the image IDB_SPLASH for 5 seconds in the center of the screen. Sample applicationYou can download a working sample application here. Related resources:DiscussDiscuss this article. Here you can write your comments and read comments of other developers. |
|||||||||||||||||||||