Splash Screen
A minimal Win32 splash screen — a borderless dialog with a bitmap that stays up for five seconds driven by a timer.
The old-school way to show a splash while an app warms up: run a picture-only dialog (the resource is just a bitmap) before your main window appears, and close it after a fixed number of timer ticks. WinMain launches the dialog; the dialog procedure starts a one-second timer in WM_INITDIALOG, and a global counter (SplashCount, bumped by a loop function the host calls during startup) ends the dialog once it reaches five. Simple, dependency-free, and still the fastest way to give users something to look at during initialization.
//---------------------------------------------------------------------------
#include "Headers/Functions.H" //----------------------------------------------------
int SplashCount;
#include "Dialogs/MainDialog.H"
//---------------------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////
extern int WINAPI WinMain (HWND hInst, HWND hPrev, LPSTR Cmd, int nCmdShow)
{
hInstance=hInst;
DialogBox(hInstance,MAKEINTRESOURCE(100),0,Clock);
return 0;
}
/////////////////////////////////////////////////////////////////////////////
extern char *loop_function (int i)
{
SplashCount++;
return "Please Wait..."; //Dialog Title Here
}
extern int Clock (HWND hDlg, int Msg, int wParam, int lParam)
{
for(;;)
{
if(Msg==WM_INITDIALOG)
{
hWnd=hDlg;
SetTimer(hWnd,1,1000,NULL);
CenterWindow(hWnd);
Update(hDlg);
break;
}
if(Msg==WM_TIMER)
{
Update(hDlg);
break;
}
if(SplashCount == 5)
{
KillTimer(hWnd,1);
EndDialog(hDlg,0);
}
break;
}
return 0;
}
The design intent: the real application's startup code calls loop_function as it progresses, so the splash closes itself when enough work has happened rather than on a pure time delay. To adapt it, make the dialog template borderless (no caption, no system menu) and put your logo bitmap as the only control.