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