1 | /* $Id: progress.c,v 1.4 1999-06-16 15:29:26 cbratschi Exp $ */
|
---|
2 | /*
|
---|
3 | * Progress control
|
---|
4 | *
|
---|
5 | * Copyright 1997 Dimitrie O. Paun
|
---|
6 | * Copyright 1998, 1999 Eric Kohl
|
---|
7 | * Copyright 1999 Achim Hasenmueller
|
---|
8 | * Copyright 1999 Christoph Bratschi
|
---|
9 | *
|
---|
10 | */
|
---|
11 |
|
---|
12 | #include "winbase.h"
|
---|
13 | #include "commctrl.h"
|
---|
14 | #include "progress.h"
|
---|
15 | #include "comctl32.h"
|
---|
16 |
|
---|
17 |
|
---|
18 | /* Control configuration constants */
|
---|
19 |
|
---|
20 | #define LED_GAP 2
|
---|
21 | #define BORDER_WIDTH 3
|
---|
22 |
|
---|
23 | /* Work constants */
|
---|
24 |
|
---|
25 | //#define UNKNOWN_PARAM(msg, wParam, lParam) WARN(progress, \
|
---|
26 | // "Unknown parameter(s) for message " #msg \
|
---|
27 | // "(%04x): wp=%04x lp=%08lx\n", msg, wParam, lParam);
|
---|
28 | #define UNKNOWN_PARAM(msg, wParam, lParam)
|
---|
29 |
|
---|
30 | #define PROGRESS_GetInfoPtr(hwnd) ((PROGRESS_INFO *)GetWindowLongA(hwnd, 0))
|
---|
31 |
|
---|
32 |
|
---|
33 | /***********************************************************************
|
---|
34 | * PROGRESS_Draw
|
---|
35 | * Draws the progress bar.
|
---|
36 | */
|
---|
37 | static void
|
---|
38 | PROGRESS_Draw (HWND hwnd, HDC hdc, INT lastVal, BOOL inUpdate)
|
---|
39 | {
|
---|
40 | PROGRESS_INFO *infoPtr = PROGRESS_GetInfoPtr(hwnd);
|
---|
41 | HBRUSH hbrBar,hbrBk,hbrLight,hbrShadow,hbrOld;
|
---|
42 | int rightBar, rightMost, ledWidth;
|
---|
43 | int lastBar;
|
---|
44 | RECT rect;
|
---|
45 | DWORD dwStyle;
|
---|
46 |
|
---|
47 | // TRACE(progress, "refresh pos=%d min=%d, max=%d\n",
|
---|
48 | // infoPtr->CurVal, infoPtr->MinVal, infoPtr->MaxVal);
|
---|
49 |
|
---|
50 | if (infoPtr->MinVal == infoPtr->MaxVal) return; //Prevent division through 0
|
---|
51 |
|
---|
52 | /* get the required bar brush */
|
---|
53 | if (infoPtr->ColorBar == CLR_DEFAULT) hbrBar = GetSysColorBrush(COLOR_HIGHLIGHT);
|
---|
54 | else hbrBar = CreateSolidBrush (infoPtr->ColorBar);
|
---|
55 |
|
---|
56 | /* get the required background brush */
|
---|
57 | if (infoPtr->ColorBk == CLR_DEFAULT) hbrBk = GetSysColorBrush (COLOR_3DFACE);
|
---|
58 | else hbrBk = CreateSolidBrush (infoPtr->ColorBk);
|
---|
59 |
|
---|
60 | /* get client rectangle */
|
---|
61 | GetClientRect (hwnd, &rect);
|
---|
62 | rect.right--;
|
---|
63 | rect.bottom--;
|
---|
64 |
|
---|
65 | /* draw the background */
|
---|
66 | if (!inUpdate)
|
---|
67 | {
|
---|
68 | FillRect(hdc, &rect, hbrBk);
|
---|
69 | //Border
|
---|
70 | hbrLight = GetSysColorBrush(COLOR_3DLIGHT);
|
---|
71 | hbrShadow = GetSysColorBrush(COLOR_3DSHADOW);
|
---|
72 | MoveToEx(hdc,rect.left,rect.bottom,NULL);
|
---|
73 | hbrOld = SelectObject(hdc,hbrShadow);
|
---|
74 | LineTo(hdc,rect.left,rect.top);
|
---|
75 | LineTo(hdc,rect.right,rect.top);
|
---|
76 | SelectObject(hdc,hbrLight);
|
---|
77 | LineTo(hdc,rect.right,rect.bottom);
|
---|
78 | LineTo(hdc,rect.left,rect.bottom);
|
---|
79 | SelectObject(hdc,hbrOld);
|
---|
80 | }
|
---|
81 |
|
---|
82 | rect.left += BORDER_WIDTH;
|
---|
83 | rect.right -= BORDER_WIDTH;
|
---|
84 | rect.top += BORDER_WIDTH;
|
---|
85 | rect.bottom -= BORDER_WIDTH;
|
---|
86 |
|
---|
87 | /* get the window style */
|
---|
88 | dwStyle = GetWindowLongA(hwnd, GWL_STYLE);
|
---|
89 |
|
---|
90 | /* compute extent of progress bar */
|
---|
91 | if (dwStyle & PBS_VERTICAL)
|
---|
92 | {
|
---|
93 | rightBar = rect.bottom-MulDiv(infoPtr->CurVal-infoPtr->MinVal,rect.bottom-rect.top,infoPtr->MaxVal-infoPtr->MinVal);
|
---|
94 | if (inUpdate) lastBar = rect.bottom-MulDiv(lastVal-infoPtr->MinVal,rect.bottom-rect.top,infoPtr->MaxVal-infoPtr->MinVal);
|
---|
95 | ledWidth = MulDiv ((rect.right - rect.left), 2, 3);
|
---|
96 | rightMost = rect.top;
|
---|
97 | }
|
---|
98 | else
|
---|
99 | {
|
---|
100 | rightBar = rect.left+MulDiv(infoPtr->CurVal-infoPtr->MinVal,rect.right-rect.left,infoPtr->MaxVal-infoPtr->MinVal);
|
---|
101 | if (inUpdate) lastBar = rect.left+MulDiv(lastVal-infoPtr->MinVal,rect.right-rect.left,infoPtr->MaxVal-infoPtr->MinVal);
|
---|
102 | ledWidth = MulDiv ((rect.bottom - rect.top), 2, 3);
|
---|
103 | rightMost = rect.right;
|
---|
104 | }
|
---|
105 |
|
---|
106 | /* now draw the bar */
|
---|
107 | if (dwStyle & PBS_SMOOTH)
|
---|
108 | {
|
---|
109 | if (dwStyle & PBS_VERTICAL)
|
---|
110 | {
|
---|
111 | if (inUpdate)
|
---|
112 | {
|
---|
113 | if (infoPtr->CurVal > lastVal)
|
---|
114 | {
|
---|
115 | rect.top = rightBar;
|
---|
116 | rect.bottom = lastBar;
|
---|
117 | FillRect(hdc,&rect,hbrBar);
|
---|
118 | } else if (infoPtr->CurVal < lastVal)
|
---|
119 | {
|
---|
120 | rect.top = lastBar;
|
---|
121 | rect.bottom = rightBar;
|
---|
122 | FillRect(hdc,&rect,hbrBk);
|
---|
123 | }
|
---|
124 | } else
|
---|
125 | {
|
---|
126 | rect.top = rightBar;
|
---|
127 | FillRect(hdc,&rect,hbrBar);
|
---|
128 | }
|
---|
129 | } else //Horizontal
|
---|
130 | {
|
---|
131 | if (inUpdate)
|
---|
132 | {
|
---|
133 | if (infoPtr->CurVal > lastVal)
|
---|
134 | {
|
---|
135 | rect.left = lastBar;
|
---|
136 | rect.right = rightBar;
|
---|
137 | FillRect(hdc,&rect,hbrBar);
|
---|
138 | } else if (infoPtr->CurVal < lastVal)
|
---|
139 | {
|
---|
140 | rect.left = rightBar;
|
---|
141 | rect.right = lastBar;
|
---|
142 | FillRect(hdc,&rect,hbrBk);
|
---|
143 | }
|
---|
144 | } else
|
---|
145 | {
|
---|
146 | rect.right = rightBar;
|
---|
147 | FillRect(hdc,&rect,hbrBar);
|
---|
148 | }
|
---|
149 | }
|
---|
150 | } else
|
---|
151 | {
|
---|
152 | if (dwStyle & PBS_VERTICAL)
|
---|
153 | {
|
---|
154 | if (inUpdate)
|
---|
155 | {
|
---|
156 | if (infoPtr->CurVal > lastVal)
|
---|
157 | {
|
---|
158 | rect.bottom -= ((int)(rect.bottom-lastBar)/(ledWidth+LED_GAP))*(ledWidth+LED_GAP);
|
---|
159 | while(rect.bottom > rightBar)
|
---|
160 | {
|
---|
161 | rect.top = rect.bottom-ledWidth;
|
---|
162 | if (rect.top < rightMost) rect.top = rightMost;
|
---|
163 | FillRect(hdc,&rect,hbrBar);
|
---|
164 | rect.bottom = rect.top-LED_GAP;
|
---|
165 | }
|
---|
166 | } else if (infoPtr->CurVal < lastVal)
|
---|
167 | {
|
---|
168 | rect.top = rect.bottom-((int)(rect.bottom-lastBar)/(ledWidth+LED_GAP))*(ledWidth+LED_GAP)-ledWidth;
|
---|
169 | if (rect.top < rightMost) rect.top = rightMost;
|
---|
170 | rect.bottom -= ((int)(rect.bottom-rightBar)/(ledWidth+LED_GAP))*(ledWidth+LED_GAP);
|
---|
171 | FillRect(hdc,&rect,hbrBk);
|
---|
172 | }
|
---|
173 | } else
|
---|
174 | {
|
---|
175 | while(rect.bottom > rightBar)
|
---|
176 | {
|
---|
177 | rect.top = rect.bottom-ledWidth;
|
---|
178 | if (rect.top < rightMost) rect.top = rightMost;
|
---|
179 | FillRect(hdc,&rect,hbrBar);
|
---|
180 | rect.bottom = rect.top-LED_GAP;
|
---|
181 | }
|
---|
182 | }
|
---|
183 | } else //Horizontal
|
---|
184 | {
|
---|
185 | if (inUpdate)
|
---|
186 | {
|
---|
187 | if (infoPtr->CurVal > lastVal)
|
---|
188 | {
|
---|
189 | rect.left += ((int)(lastBar-rect.left)/(ledWidth+LED_GAP))*(ledWidth+LED_GAP);
|
---|
190 | while(rect.left < rightBar)
|
---|
191 | {
|
---|
192 | rect.right = rect.left+ledWidth;
|
---|
193 | if (rect.right > rightMost) rect.right = rightMost;
|
---|
194 | FillRect(hdc,&rect,hbrBar);
|
---|
195 | rect.left = rect.right+LED_GAP;
|
---|
196 | }
|
---|
197 | } else if (infoPtr->CurVal < lastVal)
|
---|
198 | {
|
---|
199 | rect.right = rect.left+((int)(lastBar-rect.left)/(ledWidth+LED_GAP))*(ledWidth+LED_GAP)+ledWidth;
|
---|
200 | if (rect.right > rightMost) rect.right = rightMost;
|
---|
201 | rect.left += ((int)(rightBar-rect.left)/(ledWidth+LED_GAP))*(ledWidth+LED_GAP);
|
---|
202 | FillRect(hdc,&rect,hbrBk);
|
---|
203 | }
|
---|
204 | } else
|
---|
205 | {
|
---|
206 | while(rect.left < rightBar)
|
---|
207 | {
|
---|
208 | rect.right = rect.left+ledWidth;
|
---|
209 | if (rect.right > rightMost) rect.right = rightMost;
|
---|
210 | FillRect(hdc,&rect,hbrBar);
|
---|
211 | rect.left = rect.right+LED_GAP;
|
---|
212 | }
|
---|
213 | }
|
---|
214 | }
|
---|
215 | }
|
---|
216 |
|
---|
217 | /* delete bar brush */
|
---|
218 | if (infoPtr->ColorBar != CLR_DEFAULT) DeleteObject (hbrBar);
|
---|
219 |
|
---|
220 | /* delete background brush */
|
---|
221 | if (infoPtr->ColorBk != CLR_DEFAULT) DeleteObject (hbrBk);
|
---|
222 | }
|
---|
223 |
|
---|
224 | /***********************************************************************
|
---|
225 | * PROGRESS_Update (prototype, todo)
|
---|
226 | * Updates only the changed pixels -> faster, no flickering
|
---|
227 | */
|
---|
228 | static void PROGRESS_Update(HWND hwnd,INT lastVal)
|
---|
229 | {
|
---|
230 | PROGRESS_INFO *infoPtr = PROGRESS_GetInfoPtr(hwnd);
|
---|
231 | HDC hdc;
|
---|
232 |
|
---|
233 | if (lastVal != infoPtr->CurVal) //Only update if really necessary
|
---|
234 | {
|
---|
235 | hdc = GetDC(hwnd);
|
---|
236 | PROGRESS_Draw(hwnd,hdc,lastVal,TRUE);
|
---|
237 | ReleaseDC(hwnd,hdc);
|
---|
238 | }
|
---|
239 | }
|
---|
240 |
|
---|
241 | /***********************************************************************
|
---|
242 | * PROGRESS_Refresh
|
---|
243 | * Draw the progress bar. The background need not be erased.
|
---|
244 | */
|
---|
245 | static void
|
---|
246 | PROGRESS_Refresh (HWND hwnd)
|
---|
247 | {
|
---|
248 | HDC hdc;
|
---|
249 |
|
---|
250 | hdc = GetDC (hwnd);
|
---|
251 | PROGRESS_Draw (hwnd, hdc, 0, FALSE);
|
---|
252 | ReleaseDC (hwnd, hdc);
|
---|
253 | }
|
---|
254 |
|
---|
255 | /***********************************************************************
|
---|
256 | * PROGRESS_Paint
|
---|
257 | * Draw the progress bar. The background need not be erased.
|
---|
258 | * If dc!=0, it draws on it
|
---|
259 | */
|
---|
260 | static void
|
---|
261 | PROGRESS_Paint (HWND hwnd)
|
---|
262 | {
|
---|
263 | PAINTSTRUCT ps;
|
---|
264 | HDC hdc;
|
---|
265 |
|
---|
266 | hdc = BeginPaint (hwnd, &ps);
|
---|
267 | PROGRESS_Draw (hwnd, hdc, 0, FALSE);
|
---|
268 | EndPaint (hwnd, &ps);
|
---|
269 | }
|
---|
270 |
|
---|
271 |
|
---|
272 | /***********************************************************************
|
---|
273 | * PROGRESS_CoercePos
|
---|
274 | * Makes sure the current position (CUrVal) is within bounds.
|
---|
275 | */
|
---|
276 | static void PROGRESS_CoercePos(HWND hwnd)
|
---|
277 | {
|
---|
278 | PROGRESS_INFO *infoPtr = PROGRESS_GetInfoPtr(hwnd);
|
---|
279 |
|
---|
280 | if(infoPtr->CurVal < infoPtr->MinVal)
|
---|
281 | infoPtr->CurVal = infoPtr->MinVal;
|
---|
282 | if(infoPtr->CurVal > infoPtr->MaxVal)
|
---|
283 | infoPtr->CurVal = infoPtr->MaxVal;
|
---|
284 | }
|
---|
285 |
|
---|
286 |
|
---|
287 | /***********************************************************************
|
---|
288 | * PROGRESS_SetFont
|
---|
289 | * Set new Font for progress bar
|
---|
290 | */
|
---|
291 | static HFONT
|
---|
292 | PROGRESS_SetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
---|
293 | {
|
---|
294 | PROGRESS_INFO *infoPtr = PROGRESS_GetInfoPtr(hwnd);
|
---|
295 | HFONT hOldFont = infoPtr->hFont;
|
---|
296 |
|
---|
297 | infoPtr->hFont = (HFONT)wParam;
|
---|
298 | if (LOWORD(lParam))
|
---|
299 | PROGRESS_Refresh (hwnd);
|
---|
300 | return hOldFont;
|
---|
301 | }
|
---|
302 |
|
---|
303 |
|
---|
304 | /***********************************************************************
|
---|
305 | * ProgressWindowProc
|
---|
306 | */
|
---|
307 | LRESULT WINAPI ProgressWindowProc(HWND hwnd, UINT message,
|
---|
308 | WPARAM wParam, LPARAM lParam)
|
---|
309 | {
|
---|
310 | PROGRESS_INFO *infoPtr = PROGRESS_GetInfoPtr(hwnd);
|
---|
311 | INT temp;
|
---|
312 |
|
---|
313 | switch(message)
|
---|
314 | {
|
---|
315 | case WM_NCCREATE:
|
---|
316 | {
|
---|
317 | DWORD dwExStyle;
|
---|
318 | dwExStyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
|
---|
319 | SetWindowLongA(hwnd, GWL_EXSTYLE, dwExStyle | WS_EX_STATICEDGE);
|
---|
320 | }
|
---|
321 | return TRUE;
|
---|
322 |
|
---|
323 | case WM_CREATE:
|
---|
324 | /* allocate memory for info struct */
|
---|
325 | infoPtr =
|
---|
326 | (PROGRESS_INFO *)COMCTL32_Alloc (sizeof(PROGRESS_INFO));
|
---|
327 | SetWindowLongA(hwnd, 0, (DWORD)infoPtr);
|
---|
328 |
|
---|
329 | /* initialize the info struct */
|
---|
330 | infoPtr->MinVal=0;
|
---|
331 | infoPtr->MaxVal=100;
|
---|
332 | infoPtr->CurVal=0;
|
---|
333 | infoPtr->Step=10;
|
---|
334 | infoPtr->ColorBar=CLR_DEFAULT;
|
---|
335 | infoPtr->ColorBk=CLR_DEFAULT;
|
---|
336 | infoPtr->hFont=(HANDLE)NULL;
|
---|
337 | // TRACE(progress, "Progress Ctrl creation, hwnd=%04x\n", hwnd);
|
---|
338 | break;
|
---|
339 |
|
---|
340 | case WM_DESTROY:
|
---|
341 | // TRACE (progress, "Progress Ctrl destruction, hwnd=%04x\n", hwnd);
|
---|
342 | COMCTL32_Free (infoPtr);
|
---|
343 | break;
|
---|
344 |
|
---|
345 | case WM_ERASEBKGND:
|
---|
346 | /* pretend to erase it here, but we will do it in the paint
|
---|
347 | function to avoid flicker */
|
---|
348 | return 1;
|
---|
349 |
|
---|
350 | case WM_GETFONT:
|
---|
351 | return (LRESULT)infoPtr->hFont;
|
---|
352 |
|
---|
353 | case WM_SETFONT:
|
---|
354 | return PROGRESS_SetFont (hwnd, wParam, lParam);
|
---|
355 |
|
---|
356 | case WM_PAINT:
|
---|
357 | PROGRESS_Paint (hwnd);
|
---|
358 | break;
|
---|
359 |
|
---|
360 | case PBM_DELTAPOS:
|
---|
361 | if(lParam)
|
---|
362 | UNKNOWN_PARAM(PBM_DELTAPOS, wParam, lParam);
|
---|
363 | temp = infoPtr->CurVal;
|
---|
364 | if(wParam != 0){
|
---|
365 | infoPtr->CurVal += (INT)wParam;
|
---|
366 | PROGRESS_CoercePos (hwnd);
|
---|
367 | PROGRESS_Update (hwnd,temp);
|
---|
368 | }
|
---|
369 | return temp;
|
---|
370 |
|
---|
371 | case PBM_SETPOS:
|
---|
372 | if (lParam)
|
---|
373 | UNKNOWN_PARAM(PBM_SETPOS, wParam, lParam);
|
---|
374 | temp = infoPtr->CurVal;
|
---|
375 | if(temp != wParam){
|
---|
376 | infoPtr->CurVal = (UINT16)wParam;
|
---|
377 | PROGRESS_CoercePos(hwnd);
|
---|
378 | PROGRESS_Update (hwnd,temp);
|
---|
379 | }
|
---|
380 | return temp;
|
---|
381 |
|
---|
382 | case PBM_SETRANGE:
|
---|
383 | if (wParam)
|
---|
384 | UNKNOWN_PARAM(PBM_SETRANGE, wParam, lParam);
|
---|
385 | temp = MAKELONG(infoPtr->MinVal, infoPtr->MaxVal);
|
---|
386 | if(temp != lParam){
|
---|
387 | infoPtr->MinVal = LOWORD(lParam);
|
---|
388 | infoPtr->MaxVal = HIWORD(lParam);
|
---|
389 | if(infoPtr->MaxVal <= infoPtr->MinVal)
|
---|
390 | infoPtr->MaxVal = infoPtr->MinVal+1;
|
---|
391 | PROGRESS_CoercePos(hwnd);
|
---|
392 | PROGRESS_Refresh (hwnd);
|
---|
393 | }
|
---|
394 | return temp;
|
---|
395 |
|
---|
396 | case PBM_SETSTEP:
|
---|
397 | if (lParam)
|
---|
398 | UNKNOWN_PARAM(PBM_SETSTEP, wParam, lParam);
|
---|
399 | temp = infoPtr->Step;
|
---|
400 | infoPtr->Step = (INT)wParam;
|
---|
401 | return temp;
|
---|
402 |
|
---|
403 | case PBM_STEPIT:
|
---|
404 | if (wParam || lParam)
|
---|
405 | UNKNOWN_PARAM(PBM_STEPIT, wParam, lParam);
|
---|
406 | temp = infoPtr->CurVal;
|
---|
407 | infoPtr->CurVal += infoPtr->Step;
|
---|
408 | if(infoPtr->CurVal > infoPtr->MaxVal)
|
---|
409 | infoPtr->CurVal = infoPtr->MinVal;
|
---|
410 | if(temp != infoPtr->CurVal)
|
---|
411 | PROGRESS_Update (hwnd,temp);
|
---|
412 | return temp;
|
---|
413 |
|
---|
414 | case PBM_SETRANGE32:
|
---|
415 | temp = MAKELONG(infoPtr->MinVal, infoPtr->MaxVal);
|
---|
416 | if((infoPtr->MinVal != (INT)wParam) ||
|
---|
417 | (infoPtr->MaxVal != (INT)lParam)) {
|
---|
418 | infoPtr->MinVal = (INT)wParam;
|
---|
419 | infoPtr->MaxVal = (INT)lParam;
|
---|
420 | if(infoPtr->MaxVal <= infoPtr->MinVal)
|
---|
421 | infoPtr->MaxVal = infoPtr->MinVal+1;
|
---|
422 | PROGRESS_CoercePos(hwnd);
|
---|
423 | PROGRESS_Refresh (hwnd);
|
---|
424 | }
|
---|
425 | return temp;
|
---|
426 |
|
---|
427 | case PBM_GETRANGE:
|
---|
428 | if (lParam){
|
---|
429 | ((PPBRANGE)lParam)->iLow = infoPtr->MinVal;
|
---|
430 | ((PPBRANGE)lParam)->iHigh = infoPtr->MaxVal;
|
---|
431 | }
|
---|
432 | return (wParam) ? infoPtr->MinVal : infoPtr->MaxVal;
|
---|
433 |
|
---|
434 | case PBM_GETPOS:
|
---|
435 | if (wParam || lParam)
|
---|
436 | UNKNOWN_PARAM(PBM_STEPIT, wParam, lParam);
|
---|
437 | return (infoPtr->CurVal);
|
---|
438 |
|
---|
439 | case PBM_SETBARCOLOR:
|
---|
440 | if (wParam)
|
---|
441 | UNKNOWN_PARAM(PBM_SETBARCOLOR, wParam, lParam);
|
---|
442 | infoPtr->ColorBar = (COLORREF)lParam;
|
---|
443 | PROGRESS_Refresh (hwnd);
|
---|
444 | break;
|
---|
445 |
|
---|
446 | case PBM_SETBKCOLOR:
|
---|
447 | if (wParam)
|
---|
448 | UNKNOWN_PARAM(PBM_SETBKCOLOR, wParam, lParam);
|
---|
449 | infoPtr->ColorBk = (COLORREF)lParam;
|
---|
450 | PROGRESS_Refresh (hwnd);
|
---|
451 | break;
|
---|
452 |
|
---|
453 | default:
|
---|
454 | // if (message >= WM_USER)
|
---|
455 | // ERR(progress, "unknown msg %04x wp=%04x lp=%08lx\n",
|
---|
456 | // message, wParam, lParam );
|
---|
457 | return DefWindowProcA( hwnd, message, wParam, lParam );
|
---|
458 | }
|
---|
459 |
|
---|
460 | return 0;
|
---|
461 | }
|
---|
462 |
|
---|
463 |
|
---|
464 | /***********************************************************************
|
---|
465 | * PROGRESS_Register [Internal]
|
---|
466 | *
|
---|
467 | * Registers the progress bar window class.
|
---|
468 | */
|
---|
469 |
|
---|
470 | VOID
|
---|
471 | PROGRESS_Register (VOID)
|
---|
472 | {
|
---|
473 | WNDCLASSA wndClass;
|
---|
474 |
|
---|
475 | if (GlobalFindAtomA(PROGRESS_CLASSA)) return;
|
---|
476 |
|
---|
477 | ZeroMemory (&wndClass, sizeof( WNDCLASSA));
|
---|
478 | wndClass.style = CS_GLOBALCLASS | CS_VREDRAW | CS_HREDRAW;
|
---|
479 | wndClass.lpfnWndProc = (WNDPROC)ProgressWindowProc;
|
---|
480 | wndClass.cbClsExtra = 0;
|
---|
481 | wndClass.cbWndExtra = sizeof (PROGRESS_INFO *);
|
---|
482 | wndClass.hCursor = LoadCursorA(0, IDC_ARROWA);
|
---|
483 | wndClass.lpszClassName = PROGRESS_CLASSA;
|
---|
484 |
|
---|
485 | RegisterClassA(&wndClass);
|
---|
486 | }
|
---|
487 |
|
---|
488 |
|
---|
489 | /***********************************************************************
|
---|
490 | * PROGRESS_Unregister [Internal]
|
---|
491 | *
|
---|
492 | * Unregisters the progress bar window class.
|
---|
493 | */
|
---|
494 |
|
---|
495 | VOID
|
---|
496 | PROGRESS_Unregister (VOID)
|
---|
497 | {
|
---|
498 | if (GlobalFindAtomA(PROGRESS_CLASSA))
|
---|
499 | UnregisterClassA(PROGRESS_CLASSA, (HINSTANCE)NULL);
|
---|
500 | }
|
---|
501 |
|
---|