source: trunk/gsinstaller/splash.cpp@ 3177

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

Initial revision

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