Splash screen with text on it that uses its own thread

Download Source Code and Example


Purpose:

Shows a splash screen with extra features:
  • Enables dynamic writing of text on the splash-screen
  • Enables dynamic displaying bitmaps transparently on the splash-screen
  • All text-effects (text, sizes, fonts, positions) can be changed within a timer-procedure This allows you to create "animated" splash-screens
  • Uses a second thread, useful especially for long startup-time of application

How to use:

1. You have to create the spash within your CMainFrame::OnCreate().
Then, set bitmap, text and some other settings (text-positions and how long the splash should appear) and call CreateThread().
That's all. The thread is destroyed and deleted automatically!
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	CSplashThread *pThread = new CSplashThread();
	pThread->AddStringHeaderMain("My Application");
	// .. some other settings
	pThread->SetTimerDuration(5000); // 5 seconds
	pThread->CreateThread();


	if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;
	// ...
}
2. If you want extra features, create your own thread-class derived from CSplashThread (as done in the sample, download-size is 140 kB). Within this sample, the internal timer is activated. Each timer resets the position of the Header-text and repaints the splash. This creaes an animated splash-screen.

How it works:

* The splash-screen uses the class CSplashThread which is derived from CWinThread. The splash-Window is created from the internal CSplashThread::InitInstance(). This function is called when the thread is created with CWinThread::CreateThread().
* In InitInstance() the Splash-Window is created. Then the splash-window redirects some important messages, like painting, timer, to the creating CSplashThread-class. This class handles these messages.
* The thread is destroyed when the "finish-timer arrives" with SetTimerDuration(). It calls HideSplashScreen() (you can call this function also directly, like in the sample). HideSplashScreen() calls DestroyWindow() of the splash-window.
* If you want extras, just derive from the class and override some functions, as shown in the example.

Remarks:

* If you have enchancements to the code, mail to mloibl@moss.de
* The sample uses the function DrawTransparentBitmap(). The original code is from Q79212 and some places also here on www.codeguru.com. It is changed, because the code doesn't work with mapping-modes other than MM_TEXT
* There should be no reason for the code not working with unicode
* This code was build with MFC shipped with VC++5.0, Enterprise Edition, Service Pack 3

Last updated: 14 May 1998



Comments

  • Example app flickers

    Posted by Legacy on 09/28/2000 12:00am

    Originally posted by: Dan Colasanti

    On my machine (NT4, 466MHz P-III), the sample app's moving graphic flickers badly...

    Reply
  • Help required!!!!!!

    Posted by Legacy on 01/27/2000 12:00am

    Originally posted by: S. R.

    I want the following functionality:
    
    

    In OnCreate() of MainFrame: A modal dialog box pops up just before 'return 0' and this dialog box accepts some input(for example, your name).
    This name is displayed on the splash screen and afterwards it is terminated.

    Does anyone know how to do this?

    Reply
  • DynamicSplashScreen: Bug?

    Posted by Legacy on 03/03/1999 12:00am

    Originally posted by: Dmitry Barashev

    Something that looks like a bug was found in method 
    
    CSplashThread::DrawTransparentBitmap(). The following line:

    // Place the original bitmap back into the bitmap sent here.
    pDCTemp->BitBlt(0, 0, ptSize.x, ptSize.y - abs(ptSize.y), pDCSave, 0, 0, SRCCOPY);

    contains expression: ptSize.y - abs(ptSize.y)
    that is suspected to return zero. Thus, source bitmap becomes corrupted.
    When you try to place it one more time, you will see a wonderful
    black square.

    BarD.

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: November 20, 2014 @ 2:00 p.m. ET / 11:00 a.m. PT Are you wanting to target two or more platforms such as iOS, Android, and/or Windows? You are not alone. 90% of enterprises today are targeting two or more platforms. Attend this eSeminar to discover how mobile app developers can rely on one IDE to create applications across platforms and approaches (web, native, and/or hybrid), saving time, money, and effort and introducing apps to market faster. You'll learn the trade-offs for gaining long …

  • Live Event Date: October 29, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Are you interested in building a cognitive application using the power of IBM Watson? Need a platform that provides speed and ease for rapidly deploying this application? Join Chris Madison, Watson Solution Architect, as he walks through the process of building a Watson powered application on IBM Bluemix. Chris will talk about the new Watson Services just released on IBM bluemix, but more importantly he will do a step by step cognitive …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds