source: other-projects/gs2-export-cdrom-installer/trunk/really-really-old-stuff/splash.cpp@ 23316

Last change on this file since 23316 was 11678, checked in by mdewsnip, 18 years ago

Moved a lot of the old Borland crap into the "really-really-old-stuff" directory.

  • Property svn:keywords set to Author Date Id Revision
File size: 3.2 KB
Line 
1#include "Splash.h"
2
3#include <map>
4
5UINT timer;
6HWND splash_window;
7BOOL splash_done;
8HBITMAP splash_bmp;
9int splash_bmpheight;
10
11void CALLBACK splash_timerproc(HWND Window, UINT Message, UINT id, DWORD time)
12{ splash_done = TRUE;
13 KillTimer(NULL, 0);
14}
15
16long FAR PASCAL _export splash_windproc(HWND Window, UINT Message, WPARAM wParameter, LPARAM lParameter)
17{ switch (Message)
18 { case WM_CREATE:
19 { timer = SetTimer(NULL, 0, 3000, (TIMERPROC) splash_timerproc);
20 }
21 break;
22
23 case WM_TIMER: // valid id; just kill window after timer elapses
24 splash_done = TRUE;
25 KillTimer(Window, 0);
26 break;
27
28 case WM_DESTROY:
29 splash_window = 0;
30 break;
31
32 case WM_PAINT:
33 { PAINTSTRUCT PaintInfo;
34 HDC dc, bmpDC;
35 BITMAP bmpData;
36 POINT origin, size;
37
38 dc = BeginPaint(Window, &PaintInfo);
39 bmpDC = CreateCompatibleDC(dc);
40 SelectObject(bmpDC, splash_bmp);
41
42 GetObject(splash_bmp, sizeof(BITMAP), (LPVOID) &bmpData);
43
44 size.x = bmpData.bmWidth;
45 size.y = bmpData.bmHeight;
46 DPtoLP(dc, &size, 1);
47
48 origin.x = 0;
49 origin.y = 0;
50 DPtoLP(dc, &origin, 1);
51
52 BitBlt(dc, 0, 0, size.x, size.y,
53 bmpDC, origin.x, origin.y, SRCCOPY);
54
55 DeleteDC(bmpDC);
56 EndPaint(Window, &PaintInfo);
57 }
58 break;
59
60 case WM_COMMAND:
61 break;
62
63 default:
64 return(DefWindowProc(Window, Message, wParameter, lParameter));
65 }
66 return 0L;
67}
68
69void splash_register(HINSTANCE instance)
70{ WNDCLASS Class;
71 static bool registered = false;
72 if (registered == false)
73 { Class.lpszClassName = "Generic:Splash";
74 Class.hInstance = instance;
75 Class.lpfnWndProc = (WNDPROC) splash_windproc;
76 Class.hCursor = LoadCursor(NULL, IDC_ARROW);
77 Class.hIcon = NULL;
78 Class.lpszMenuName = NULL;
79 Class.hbrBackground = (HBRUSH) (COLOR_WINDOW+1);
80 Class.style = NULL;
81 Class.cbClsExtra = 0;
82 Class.cbWndExtra = 0;
83 RegisterClass(&Class);
84 registered = TRUE;
85 }
86}
87
88void _export splash_show(HINSTANCE instance, unsigned int time)
89{ MSG msg;
90 RECT r;
91 BITMAP bmpData;
92 POINT size;
93 int sx, sy;
94 HDC dc;
95
96 splash_register(instance);
97
98 splash_bmp = LoadBitmap(instance, (LPCSTR) MAKEINTRESOURCE(9007));
99 splash_done = FALSE;
100
101 GetObject(splash_bmp, sizeof(BITMAP), (LPVOID) &bmpData);
102 size.x = bmpData.bmWidth;
103 size.y = bmpData.bmHeight;
104
105 r.left = 0;
106 r.top = 0;
107 r.right = size.x;
108 r.bottom = size.y;
109 AdjustWindowRect(&r, 0, TRUE);
110
111 splash_bmpheight = size.y;
112 dc = GetDC(GetDesktopWindow());
113 sx = GetDeviceCaps(dc, HORZRES);
114 sy = GetDeviceCaps(dc, VERTRES);
115 ReleaseDC(GetDesktopWindow(), dc);
116
117 splash_window = CreateWindow("Generic:Splash", "Greenstone Installer",
118 WS_DLGFRAME | WS_VISIBLE,
119 (sx - r.right + r.left) / 2,
120 (sy - r.bottom + r.top) / 2,
121 r.right-r.left, r.bottom-r.top,
122 0, 0, instance, NULL);
123 while (GetMessage(&msg, NULL, NULL, NULL) &&
124 splash_done == FALSE)
125 { if (msg.message == WM_TIMER)
126 { msg.hwnd = splash_window;
127 }
128 TranslateMessage(&msg);
129 DispatchMessage(&msg);
130 }
131 DestroyWindow(splash_window);
132}
133
Note: See TracBrowser for help on using the repository browser.