Splasher
v1.59 An improved splash
screen component for MFC
This provides a number of advantages over and above the standard splash
screen component that was included with early versions of VC++.
- The code can optionally use an external image instead of a bitmap
resource. This allows your splash screen to be easily customized at run time without the
need to change a bitmap resource inside your exe. For example you could ship two versions
of bitmap files, one for 16 color screens and a 256 color bitmap for higher screen depths.
You could also allow your end user to change the splash screen.
- The palette from the image is read from file and is used to provide
support for more colors that the standard 16 which are available with bitmap resources.
- The splash screen component is multi-threaded, meaning that it remains
responsive and redraws itself correctly while you can be loading up your
application (and not necessarily pumping the message queue) in
the normal MFC InitInstance override.
- The splash screen is coded so that it will only be brought down when
you want it to, not when the user clicks on it or a timer expires. This allows you to
close it down exactly when your application is ready for input and no longer needs to
display the splash screen.
- Bitmap which is to be displayed can be drawn transparently and with an
alpha channel.
- Supports any image formats which can be loaded via ATL::CImage.
A sample SDI AppWizard generated application is included which
demonstrates it use. To incorporate the splash screen component you will just need to add
approximately 10 lines of code to your applications InitInstance function. Also
included is a sample dialog AppWizard generated application.
The enclosed zip file contains
the source and a VC2017 sample SDI and Dialog based AppWizard generated application to show how to use it.
Copyright
- You are allowed to include the source code in
any product (commercial, shareware, freeware or otherwise) when your product
is released in binary form.
- You are allowed to modify the source code in
any way you want except you cannot modify the copyright details at the top
of each module.
- If you want to distribute source code with
your application, then you are only allowed to distribute versions released
by the author. This is to maintain a single distribution point for the
source code.
Updates
v1.59 (2 April 2022)
- Updated copyright details.
- Updated the code to use C++ uniform initialization for all variable
declarations
- Replaced ATL::CHeapPtr usage with std::vector.
v1.58 (29 March 2020)
- Updated copyright details.
- Fixed more Clang-Tidy static code analysis warnings in the code.
v1.57 (26 December 2019)
- Fixed various Clang-Tidy static code analysis warnings in the code.
- Replaced BOOL with bool throughout the code.
v1.56 (21 September 2019)
- Fixed a number of compiler warnings when the code is compiled with VS
2019 Preview
v1.55 (2 June 2019)
- Updated copyright details.
- Updated the code to clean compile on VC 2019
V1.54 (29 September 2018)
- Updated copyright details
- Fixed a number of C++ core guidelines compiler warnings. These changes
mean that the code will now only compile on VC 2017 or later.
- Replaced NULL throughout the codebase with nullptr
- Code no longer uses GetProcAddress to access SetLayeredWindowAttributes
API
- Reworked the code to use ATL::CImage for the splash screen bitmap
- Updated the SetBitmapToUse method to include an instance handle
parameter to load the image from
V1.53 (10 January 2016)
- Updated copyright details
- Verified the code compiles cleanly on VC 2015.
- Added SAL annotations to all the code.
V1.52 (18 January 2015)
- Updated copyright details
- Updated the code and sample app to clean compile on VC 2013
V1.51 (22 September 2013)
- Updated copyright details
- Updated the code and sample app to clean compile on VC 2012
- Updated CSplashWnd::LoadBitmap to use AfxFindResourceHandle when
locating the bitmap. Thanks to Emeric Maschino for this nice addition.
V1.50 (17 May 2009)
- Updated copyright details
- Removed VC 6 style class wizard comments from the code.
- Updated code to compile correctly using _ATL_CSTRING_EXPLICIT_CONSTRUCTORS
define
- Updated CSplashWnd::SetTransparent to allow the alpha transparency level
as well as the flags passed to SetLayeredWindowAttributes to be completed
specified
- Updated code to clean compile on VC 2008.
- Code now compiles cleanly using Code Analysis (/analyze)
- The code now only supports VC 2005 or later.
V1.49 (17 November 2007)
- Fixed a memory leak where the CMySplashWnd instance was not being
deleted in the worker thread. Thanks to Laurent Lherminé for reporting this
bug.
V1.48 (13 October 2007)
- CSplashFactory::Create now by default creates the splash screen thread
at normal priority instead of idle priority. This helps avoid thread
starvation issues when the main thread is busy performing its startup code.
Please be aware of this issue if you modify your applications main thread
priority to be anything other than THREAD_PRIORITY_NORMAL. If you do please
make sure that the nPriority value to CSplashFactory::Create is >= the value
you use for your main thread, or otherwise you will starve the splash screen
of CPU cycles on a single core processor. Thanks to Ralf Magnussen for
reporting this issue.
V1.47 (22 July 2007)
- Updated copyright details.
- Optimized CSplashFactory constructor code
- CSplashWnd code now uses WM_NCHITTEST logic to support a draggable
splash screen
- Made Create and Close methods in CSplashFactory virtual
- CSplashFactory::Create now waits for the worker thread's InitInstance to
complete
- Removed unnecessary VERIFY call from CSplashWnd::Create
- CSplashWnd::CreatePaletteFromBitmap now returns a BOOL
- Removed the unnecessary CSplashWnd destructor
- Removed the unnecessary CSplashThread destructor.
- Reviewed all TRACE statements for correctness
- Removed unnecessary use of friend classes
- Updated sample apps to clean compile on VC2005
V1.46 (9 July 2006)
- Updated the code to clean compile on VC 2005.
- Updated copyright details.
- Addition of CSPLASHER_EXT_CLASS macro to allow the classes to be easily
added to an extension dll.
- Code now uses newer C++ style casts instead of C style casts.
- Optimized CSplashWnd constructor code
- Optimized CSplashThread constructor code
- Reviewed all TRACE statements for correctness.
- UI thread which is created by the code is now created at idle priority
- Updated the documentation to use the same style as the web site.
V1.45 (9 May 2004)
- Updated the copyright details
- Included a new sample app in the download to
demonstrate the correct usage of the splash screen in a dialog based app.
- Fixed a bug where sometimes the splash screen component
would get stuck while waiting for the splash screen thread to exit. The fix is to
request the parent window to exit in CSplashWnd::OnClose. Thanks to Frederic
Metrich for reporting this issue.
V1.44 (6 September 2003)
- Fixed a problem where you get a crash in the close
method if the window to gain focus was NULL. Thanks to Darius Thabit for
reporting this problem.
V1.43 (28 August 2003)
- Removed a number of level 4 warnings.
V1.42 (11 October 2002)
- Fixed up some coding issues reported by BoundsChecker in CSplashWnd::OnPaint.
- Now supports a drop shadow effect on the splash screen (assuming that the client OS is Windows XP or later).
V1.41 (3 October 2002)
- Now allows you to specify a transparent color to draw
the splash screen with. This allows you to realize shapes other than the
standard rectangle. Thanks to Gero Gerber for this update. Please note that
this support is only available on Windows 2000 or later.
- Made the destructor of CSplashWnd virtual
V1.4 (31 August 2001)
- Fixed an assert which was occurring when you brought up
the splash window and closed it really quickly. Thanks to Wanner Robert for
spotting this problem.
- Removed a busy loop in HideSplash and used a Win32
event for synchronisation instead.
- Implemented a class factory design pattern to further
simplify the use of the splash screen class. All client code now needs to do
is derive a class from CSplashWnd (making sure it's declared DYNCREATE) and
at a minimum just call some of it's methods in the constructor to determine
what it will display at runtime. Then just use CSplashFactory::Create with
the name of your derived class. When you want to close the splash screen
just call CSplashFactory::Create. What could be simpler!!!.
V1.34 (27 August 2001)
- Splash screen now by default includes the window style
WS_EX_TOPMOST.
V1.33 (1 January 2001)
- Now includes copyright message in the source code and
documentation.
- Modified the way the sample app waits for the thread to
exit. It now synchronises with the exit of the splash screen thread
- Now allows the icon of the splash screen to be
specified
- Now allows the splash screen window to be customized at
run time through a virtual function "CSplashThread::CreateSplash".
Thanks to Yury Goltsman for suggesting these enhancements.
V1.32 (1 March 2000)
- Fixed a problem with bitmaps which do not have a
palette (Again <g>)
- Fixed a problem in Win 98 and Win2000 when the splash
screen is closed but the main window of your app fails to activate. The code
now uses AttachThreadInput to synchronise the UI activities of the main GUI
thread and the splash screen thread.
V1.31 (21 June 1999)
- Fixed a bug which was causing an assert when loading up a bitmap which does not have an associated palette.
V1.3 (22 December 1998)
- Now provided VC 5 workspace files as standard
- Removed the dependence of splasher on CDibImage (another shareware
product of the author).
- Provision of HTML help file (this file) describing the class.
- The code is now UNICODE enabled and UNICODE build configurations are
provided in the sample app.
- General tidy up of the code
- Fixed a potential race condition in CSplashThread::HideSplash()
- Reduced the size of the zip file by only including the demo bitmap
once.
V1.2 (22 March 1998)
- Palette is now correctly initialized on startup
- Code now protects itself if m_SplashScreen cannot be created.
V1.1 (11 December 1997)
- Incorporation of new DIB code provided by the authors own CDibImage
class. A static library version is used by splasher here. If you want to use CDIbImage for
anything other than CSplashThread, then you need to download CDibImage on its own.
- Can now load from resource or bitmap
- General tidy up of the code.
V1.0 (15 November 1996)