** Start Your Applications with a SPLASH of Class **
** By Matthew J. W. Ratcliff                      **
** Ratware Softworks                              **


  (c) Ratware Softworks 1995 - Matthew J. W. Ratcliff - Free to use in your
  applications if this copyright notice remains in the source code and
  this document.

** Abstract **

When you're finally ready to release a product, it would be nice to integrate
a snappy splash screen that comes up immediately while the rest of the
application loads and initializes.  This requires integrating some new
resources and support code into your application, adding to the bulk of your
hefty masterpiece.  I have taken a different approach with my "Splash" class.
With this class you can very easily create a small application that quickly
loads, displays your logo, optionally plays a wave file, and then "launches"
your main application with the use of "WinExec".

This approach also has some advantages in launching "remote" applications from
a network or CD-ROM.  For example, when you change resolution in Windows, all
your icons are regenerated from their applications.  If the application cannot
be found at this time, your icon is replaced with an empty CRT icon.  This can
be a pain if you have multiple applications that run directly from CD, you're
going to lose all of them except for the one that's currently in the CD-ROM
drive.  Also, if you are connected to multiple remote network applications,
but are not logged onto the network at the time of resolution change, all
those icons are lost too. It's tedious to regenerate them.  But you can easily
use the "Splash" class to create a local program with the application's icon,
that launches the remote application for you.

** Resources **

Your first step is to create a resource file for your "Splash", similar to
that shown in the listing below (file splashts.rc - splash test resource
file):

     /********************************************************************
      *                                                                  *
      *   Source File: SPLASHTS.rc                                       *
      *   Description: Resource file for SPLASHTS - Splash class test    *
      *   Date:        Fri  01-21-1994  08:42:55                         *
      *                                                                  *
      ********************************************************************/

SPLASHICON      ICON    "SPLASHTS.ICO"
SPLASH          BITMAP  "SPLASHTS.BMP"
SPLASHSPEAK     WAVE    "SPLASHTS.WAV"


The resource file must contain an entry labeled "SPLASHICON" which calls out
the icon file for your launch program.  This should be the same icon file as
the application it will launch.  (If you don't have source code to the
application, many resource editors can extract icons from .EXE files for you.)
Next create a bitmap for your application.  This should be a standard Windows
.BMP file.  This can be any 16 or 256 color image.  It should be small enough
to fit reasonably on a 640x480 display, the lowest common denominator for
Windows applications.  This bitmap file should be called out in the resource
file with the label "SPLASH".  If you wish to have the launcher also play a
wave file at startup, call out that wave file on with a label of
"SPLASHSPEAK".  I would advise this only for game programs however; wave files
being played in an office envronment are usually frowned upon.

** Constructing The Launcher **

Virtually all of the work is done for you in "SPLASH.CPP". The launcher
program itself is only a few lines of code, as shown in SPLASHTS.CPP,
abbreviated below:

//  abbreviated listing, see splashts.cpp:
#include <windows.h>
#include "portable.h"
#include "splash.h"

int PASCAL WinMain( HANDLE pasHinstance,
                    HANDLE pasHprevInstance,
                    LPSTR  pasLpszCmdLine,
                    int    pasNcmdShow )
{
/*********** Local Constant & Variable Declarations *******************/
Splash          *splSplash;
int              splResult;
/************************* Procedure Body *****************************/
splSplash = new Splash( pasHinstance,
                        pasHprevInstance,
                        pasLpszCmdLine,
                        pasNcmdShow );

splResult = splSplash->Launch( 8000, // show for 8 seconds
                               "notepad.exe", // run notepad editor
                               FALSE ); // Don't extract path

LIMDEL(splSplash);
return( splResult );
} /* WinMain end */


Call the "Splash" constructor with the same parameters that are passed to your
"WinMain".  Then, simply call the "Launch" member function specifying the
numer of milliseconds to display the splash bitmap, the name of the
application to execute, and a flag telling Splash whether to extract the path
or not.  The third parameter, if TRUE, tells Splash to get the entire path of
this launch program and prepend it to the second parameter, the program to be
executed.  This is best to use when you "know" (because that's how your setup
installed the application) the launcher and application are in the same
directory.  If the application to be launched may not be in the same directory
as the launcher, but is in the system search path, for example, then pass
FALSE for the third parameter.  You may optionally specify the full path to
the application in the second parameter to Launch, in which case the third
parameter should be FALSE.  The command line that is passed to your launcher
is passed, unmodified, to the application it launches.  Thus, if the launched
application needs information from the command line, you may setup the command
line for the launcher and it will be forwarded for you.


This is the definitions file for the SPLASHTS program:

;-----------------------------------
; SPLASHTS.DEF module definition file
;-----------------------------------

NAME
DESCRIPTION    'Splash Test by Mat*Rat'
; Comment out following 2 lines if building under Win32 ('95 or NT)
EXETYPE        WINDOWS
STUB           'WINSTUB.EXE'
CODE           PRELOAD MOVEABLE DISCARDABLE
DATA           PRELOAD MOVEABLE MULTIPLE
HEAPSIZE       4096
STACKSIZE      10000


Let me know if you have any questions, comments, problems.

Matthew J. W. Ratcliff
Ratware Softworks
Mat.Rat on GEnie
76711,1443 on CompuServe

