source: trunk/gsinstaller/splash.c@ 1397

Last change on this file since 1397 was 1397, checked in by cs025, 24 years ago

Initial revision

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