#include "Splash.h" #define bool int #define false 0 #define true 1 UINT timer; HWND splash_window; BOOL splash_done; HBITMAP splash_bmp; int splash_bmpheight; void CALLBACK splash_timerproc(HWND Window, UINT Message, UINT id, DWORD time) { splash_done = TRUE; KillTimer(NULL, 0); } long FAR PASCAL _export splash_windproc(HWND Window, UINT Message, WPARAM wParameter, LPARAM lParameter) { switch (Message) { case WM_CREATE: { timer = SetTimer(NULL, 0, 3000, (TIMERPROC) splash_timerproc); } break; case WM_TIMER: // valid id; just kill window after timer elapses splash_done = TRUE; KillTimer(Window, 0); break; case WM_DESTROY: splash_window = 0; break; case WM_PAINT: { PAINTSTRUCT PaintInfo; HDC dc, bmpDC; BITMAP bmpData; POINT origin, size; dc = BeginPaint(Window, &PaintInfo); bmpDC = CreateCompatibleDC(dc); SelectObject(bmpDC, splash_bmp); GetObject(splash_bmp, sizeof(BITMAP), (LPVOID) &bmpData); size.x = bmpData.bmWidth; size.y = bmpData.bmHeight; DPtoLP(dc, &size, 1); origin.x = 0; origin.y = 0; DPtoLP(dc, &origin, 1); BitBlt(dc, 0, 0, size.x, size.y, bmpDC, origin.x, origin.y, SRCCOPY); DeleteDC(bmpDC); EndPaint(Window, &PaintInfo); } break; case WM_COMMAND: break; default: return(DefWindowProc(Window, Message, wParameter, lParameter)); } return 0L; } void splash_register(HINSTANCE instance) { WNDCLASS Class; static bool registered = false; if (registered == false) { Class.lpszClassName = "Generic:Splash"; Class.hInstance = instance; Class.lpfnWndProc = (WNDPROC) splash_windproc; Class.hCursor = LoadCursor(NULL, IDC_ARROW); Class.hIcon = NULL; Class.lpszMenuName = NULL; Class.hbrBackground = (HBRUSH) (COLOR_WINDOW+1); Class.style = NULL; Class.cbClsExtra = 0; Class.cbWndExtra = 0; RegisterClass(&Class); registered = TRUE; } } void _export splash_show(HINSTANCE instance, unsigned int time) { MSG msg; RECT r; BITMAP bmpData; POINT size; int sx, sy; HDC dc; splash_register(instance); splash_bmp = LoadBitmap(instance, (LPCSTR) MAKEINTRESOURCE(9007)); splash_done = FALSE; GetObject(splash_bmp, sizeof(BITMAP), (LPVOID) &bmpData); size.x = bmpData.bmWidth; size.y = bmpData.bmHeight; r.left = 0; r.top = 0; r.right = size.x; r.bottom = size.y; AdjustWindowRect(&r, 0, TRUE); splash_bmpheight = size.y; dc = GetDC(GetDesktopWindow()); sx = GetDeviceCaps(dc, HORZRES); sy = GetDeviceCaps(dc, VERTRES); ReleaseDC(GetDesktopWindow(), dc); splash_window = CreateWindow("Generic:Splash", "Greenstone Installer", WS_DLGFRAME | WS_VISIBLE, (sx - r.right + r.left) / 2, (sy - r.bottom + r.top) / 2, r.right-r.left, r.bottom-r.top, 0, 0, instance, NULL); while (GetMessage(&msg, NULL, NULL, NULL) && splash_done == FALSE) { if (msg.message == WM_TIMER) { msg.hwnd = splash_window; } TranslateMessage(&msg); DispatchMessage(&msg); } DestroyWindow(splash_window); }