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

  • On-demand Event Event Date: December 18, 2014 The Internet of Things (IoT) incorporates physical devices into business processes using predictive analytics. While it relies heavily on existing Internet technologies, it differs by including physical devices, specialized protocols, physical analytics, and a unique partner network. To capture the real business value of IoT, the industry must move beyond customized projects to general patterns and platforms. Check out this webcast and join industry experts as …

  • On-demand Event Event Date: October 29, 2014 It's well understood how critical version control is for code. However, its importance to DevOps isn't always recognized. The 2014 DevOps Survey of Practice shows that one of the key predictors of DevOps success is putting all production environment artifacts into version control. In this webcast, Gene Kim discusses these survey findings and shares woeful tales of artifact management gone wrong! Gene also shares examples of how high-performing DevOps …

Most Popular Programming Stories

More for Developers

RSS Feeds