msi: Add support for updating rows in join tables.
[wine/multimedia.git] / dlls / comctl32 / progress.c
blobc44b816a2b826443948315bbd820f6a4f80bd963
1 /*
2 * Progress control
4 * Copyright 1997, 2002 Dimitrie O. Paun
5 * Copyright 1998, 1999 Eric Kohl
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 * NOTE
23 * This code was audited for completeness against the documented features
24 * of Comctl32.dll version 6.0 on Sep. 9, 2002, by Dimitrie O. Paun.
26 * Unless otherwise noted, we believe this code to be complete, as per
27 * the specification mentioned above.
28 * If you discover missing features, or bugs, please note them below.
30 * TODO:
32 * Messages:
33 * -- PBM_GETSTEP
34 * -- PBM_SETSTATE
35 * -- PBM_GETSTATE
37 * Styles:
38 * -- PBS_SMOOTHREVERSE
42 #include <stdarg.h>
43 #include <string.h>
44 #include "windef.h"
45 #include "winbase.h"
46 #include "wingdi.h"
47 #include "winuser.h"
48 #include "winnls.h"
49 #include "commctrl.h"
50 #include "comctl32.h"
51 #include "uxtheme.h"
52 #include "tmschema.h"
53 #include "wine/debug.h"
55 WINE_DEFAULT_DEBUG_CHANNEL(progress);
57 typedef struct
59 HWND Self; /* The window handle for this control */
60 INT CurVal; /* Current progress value */
61 INT MinVal; /* Minimum progress value */
62 INT MaxVal; /* Maximum progress value */
63 INT Step; /* Step to use on PMB_STEPIT */
64 INT MarqueePos; /* Marquee animation position */
65 BOOL Marquee; /* Whether the marquee animation is enabled */
66 COLORREF ColorBar; /* Bar color */
67 COLORREF ColorBk; /* Background color */
68 HFONT Font; /* Handle to font (not unused) */
69 } PROGRESS_INFO;
71 /* Control configuration constants */
73 #define LED_GAP 2
74 #define MARQUEE_LEDS 5
75 #define ID_MARQUEE_TIMER 1
77 /* Helper to obtain size of a progress bar chunk ("led"). */
78 static inline int get_led_size ( const PROGRESS_INFO *infoPtr, LONG style,
79 const RECT* rect )
81 HTHEME theme = GetWindowTheme (infoPtr->Self);
82 if (theme)
84 int chunkSize;
85 if (SUCCEEDED( GetThemeInt( theme, 0, 0, TMT_PROGRESSCHUNKSIZE, &chunkSize )))
86 return chunkSize;
89 if (style & PBS_VERTICAL)
90 return MulDiv (rect->right - rect->left, 2, 3);
91 else
92 return MulDiv (rect->bottom - rect->top, 2, 3);
95 /* Helper to obtain gap between progress bar chunks */
96 static inline int get_led_gap ( const PROGRESS_INFO *infoPtr )
98 HTHEME theme = GetWindowTheme (infoPtr->Self);
99 if (theme)
101 int spaceSize;
102 if (SUCCEEDED( GetThemeInt( theme, 0, 0, TMT_PROGRESSSPACESIZE, &spaceSize )))
103 return spaceSize;
106 return LED_GAP;
109 /* Get client rect. Takes into account that theming needs no adjustment. */
110 static inline void get_client_rect (HWND hwnd, RECT* rect)
112 HTHEME theme = GetWindowTheme (hwnd);
113 GetClientRect (hwnd, rect);
114 if (!theme)
115 InflateRect(rect, -1, -1);
116 else
118 DWORD dwStyle = GetWindowLongW (hwnd, GWL_STYLE);
119 int part = (dwStyle & PBS_VERTICAL) ? PP_BARVERT : PP_BAR;
120 GetThemeBackgroundContentRect (theme, 0, part, 0, rect, rect);
124 /* Compute the extend of the bar */
125 static inline int get_bar_size( LONG style, const RECT* rect )
127 if (style & PBS_VERTICAL)
128 return rect->bottom - rect->top;
129 else
130 return rect->right - rect->left;
133 /* Compute the pixel position of a progress value */
134 static inline int get_bar_position( const PROGRESS_INFO *infoPtr, LONG style,
135 const RECT* rect, INT value )
137 return MulDiv (value - infoPtr->MinVal, get_bar_size (style, rect),
138 infoPtr->MaxVal - infoPtr->MinVal);
141 /***********************************************************************
142 * PROGRESS_Invalidate
144 * Don't be too clever about invalidating the progress bar.
145 * InstallShield depends on this simple behaviour.
147 static void PROGRESS_Invalidate( const PROGRESS_INFO *infoPtr, INT old, INT new )
149 InvalidateRect( infoPtr->Self, NULL, old > new );
152 /* Information for a progress bar drawing helper */
153 typedef struct tagProgressDrawInfo
155 HDC hdc;
156 RECT rect;
157 HBRUSH hbrBar;
158 HBRUSH hbrBk;
159 int ledW, ledGap;
160 HTHEME theme;
161 RECT bgRect;
162 } ProgressDrawInfo;
164 typedef void (*ProgressDrawProc)(const ProgressDrawInfo* di, int start, int end);
166 /* draw solid horizontal bar from 'start' to 'end' */
167 static void draw_solid_bar_H (const ProgressDrawInfo* di, int start, int end)
169 RECT r;
170 r.left = di->rect.left + start;
171 r.top = di->rect.top;
172 r.right = di->rect.left + end;
173 r.bottom = di->rect.bottom;
174 FillRect (di->hdc, &r, di->hbrBar);
177 /* draw solid horizontal background from 'start' to 'end' */
178 static void draw_solid_bkg_H (const ProgressDrawInfo* di, int start, int end)
180 RECT r;
181 r.left = di->rect.left + start;
182 r.top = di->rect.top;
183 r.right = di->rect.left + end;
184 r.bottom = di->rect.bottom;
185 FillRect (di->hdc, &r, di->hbrBk);
188 /* draw solid vertical bar from 'start' to 'end' */
189 static void draw_solid_bar_V (const ProgressDrawInfo* di, int start, int end)
191 RECT r;
192 r.left = di->rect.left;
193 r.top = di->rect.bottom - end;
194 r.right = di->rect.right;
195 r.bottom = di->rect.bottom - start;
196 FillRect (di->hdc, &r, di->hbrBar);
199 /* draw solid vertical background from 'start' to 'end' */
200 static void draw_solid_bkg_V (const ProgressDrawInfo* di, int start, int end)
202 RECT r;
203 r.left = di->rect.left;
204 r.top = di->rect.bottom - end;
205 r.right = di->rect.right;
206 r.bottom = di->rect.bottom - start;
207 FillRect (di->hdc, &r, di->hbrBk);
210 /* draw chunky horizontal bar from 'start' to 'end' */
211 static void draw_chunk_bar_H (const ProgressDrawInfo* di, int start, int end)
213 RECT r;
214 int right = di->rect.left + end;
215 r.left = di->rect.left + start;
216 r.top = di->rect.top;
217 r.bottom = di->rect.bottom;
218 while (r.left < right)
220 r.right = min (r.left + di->ledW, right);
221 FillRect (di->hdc, &r, di->hbrBar);
222 r.left = r.right;
223 r.right = min (r.left + di->ledGap, right);
224 FillRect (di->hdc, &r, di->hbrBk);
225 r.left = r.right;
229 /* draw chunky vertical bar from 'start' to 'end' */
230 static void draw_chunk_bar_V (const ProgressDrawInfo* di, int start, int end)
232 RECT r;
233 int top = di->rect.bottom - end;
234 r.left = di->rect.left;
235 r.right = di->rect.right;
236 r.bottom = di->rect.bottom - start;
237 while (r.bottom > top)
239 r.top = max (r.bottom - di->ledW, top);
240 FillRect (di->hdc, &r, di->hbrBar);
241 r.bottom = r.top;
242 r.top = max (r.bottom - di->ledGap, top);
243 FillRect (di->hdc, &r, di->hbrBk);
244 r.bottom = r.top;
248 /* drawing functions for "classic" style */
249 static const ProgressDrawProc drawProcClassic[8] = {
250 /* Smooth */
251 /* Horizontal */
252 draw_solid_bar_H, draw_solid_bkg_H,
253 /* Vertical */
254 draw_solid_bar_V, draw_solid_bkg_V,
255 /* Chunky */
256 /* Horizontal */
257 draw_chunk_bar_H, draw_solid_bkg_H,
258 /* Vertical */
259 draw_chunk_bar_V, draw_solid_bkg_V,
262 /* draw themed horizontal bar from 'start' to 'end' */
263 static void draw_theme_bar_H (const ProgressDrawInfo* di, int start, int end)
265 RECT r;
266 r.left = di->rect.left + start;
267 r.top = di->rect.top;
268 r.bottom = di->rect.bottom;
269 r.right = di->rect.left + end;
270 DrawThemeBackground (di->theme, di->hdc, PP_CHUNK, 0, &r, NULL);
273 /* draw themed vertical bar from 'start' to 'end' */
274 static void draw_theme_bar_V (const ProgressDrawInfo* di, int start, int end)
276 RECT r;
277 r.left = di->rect.left;
278 r.right = di->rect.right;
279 r.bottom = di->rect.bottom - start;
280 r.top = di->rect.bottom - end;
281 DrawThemeBackground (di->theme, di->hdc, PP_CHUNKVERT, 0, &r, NULL);
284 /* draw themed horizontal background from 'start' to 'end' */
285 static void draw_theme_bkg_H (const ProgressDrawInfo* di, int start, int end)
287 RECT r;
288 r.left = di->rect.left + start;
289 r.top = di->rect.top;
290 r.right = di->rect.left + end;
291 r.bottom = di->rect.bottom;
292 DrawThemeBackground (di->theme, di->hdc, PP_BAR, 0, &di->bgRect, &r);
295 /* draw themed vertical background from 'start' to 'end' */
296 static void draw_theme_bkg_V (const ProgressDrawInfo* di, int start, int end)
298 RECT r;
299 r.left = di->rect.left;
300 r.top = di->rect.bottom - end;
301 r.right = di->rect.right;
302 r.bottom = di->rect.bottom - start;
303 DrawThemeBackground (di->theme, di->hdc, PP_BARVERT, 0, &di->bgRect, &r);
306 /* drawing functions for themed style */
307 static const ProgressDrawProc drawProcThemed[8] = {
308 /* Smooth */
309 /* Horizontal */
310 draw_theme_bar_H, draw_theme_bkg_H,
311 /* Vertical */
312 draw_theme_bar_V, draw_theme_bkg_V,
313 /* Chunky */
314 /* Horizontal */
315 draw_theme_bar_H, draw_theme_bkg_H,
316 /* Vertical */
317 draw_theme_bar_V, draw_theme_bkg_V,
320 /***********************************************************************
321 * PROGRESS_Draw
322 * Draws the progress bar.
324 static LRESULT PROGRESS_Draw (PROGRESS_INFO *infoPtr, HDC hdc)
326 int barSize;
327 DWORD dwStyle;
328 BOOL barSmooth;
329 const ProgressDrawProc* drawProcs;
330 ProgressDrawInfo pdi;
332 TRACE("(infoPtr=%p, hdc=%p)\n", infoPtr, hdc);
334 pdi.hdc = hdc;
335 pdi.theme = GetWindowTheme (infoPtr->Self);
337 /* get the required bar brush */
338 if (infoPtr->ColorBar == CLR_DEFAULT)
339 pdi.hbrBar = GetSysColorBrush(COLOR_HIGHLIGHT);
340 else
341 pdi.hbrBar = CreateSolidBrush (infoPtr->ColorBar);
343 if (infoPtr->ColorBk == CLR_DEFAULT)
344 pdi.hbrBk = GetSysColorBrush(COLOR_3DFACE);
345 else
346 pdi.hbrBk = CreateSolidBrush(infoPtr->ColorBk);
348 /* get the window style */
349 dwStyle = GetWindowLongW (infoPtr->Self, GWL_STYLE);
351 /* get client rectangle */
352 GetClientRect (infoPtr->Self, &pdi.rect);
353 if (!pdi.theme) {
354 FrameRect( hdc, &pdi.rect, pdi.hbrBk );
355 InflateRect(&pdi.rect, -1, -1);
357 else
359 RECT cntRect;
360 int part = (dwStyle & PBS_VERTICAL) ? PP_BARVERT : PP_BAR;
362 GetThemeBackgroundContentRect (pdi.theme, hdc, part, 0, &pdi.rect,
363 &cntRect);
365 /* Exclude content rect - content background will be drawn later */
366 ExcludeClipRect (hdc, cntRect.left, cntRect.top,
367 cntRect.right, cntRect.bottom);
368 if (IsThemeBackgroundPartiallyTransparent (pdi.theme, part, 0))
369 DrawThemeParentBackground (infoPtr->Self, hdc, NULL);
370 DrawThemeBackground (pdi.theme, hdc, part, 0, &pdi.rect, NULL);
371 SelectClipRgn (hdc, NULL);
372 CopyRect (&pdi.rect, &cntRect);
375 /* compute some drawing parameters */
376 barSmooth = (dwStyle & PBS_SMOOTH) && !pdi.theme;
377 drawProcs = &((pdi.theme ? drawProcThemed : drawProcClassic)[(barSmooth ? 0 : 4)
378 + ((dwStyle & PBS_VERTICAL) ? 2 : 0)]);
379 barSize = get_bar_size( dwStyle, &pdi.rect );
380 if (pdi.theme)
382 GetWindowRect( infoPtr->Self, &pdi.bgRect );
383 ScreenToClient( infoPtr->Self, (POINT*)&pdi.bgRect );
384 ScreenToClient( infoPtr->Self, (POINT*)&pdi.bgRect.right );
387 if (!barSmooth)
388 pdi.ledW = get_led_size( infoPtr, dwStyle, &pdi.rect);
389 pdi.ledGap = get_led_gap( infoPtr );
391 if (dwStyle & PBS_MARQUEE)
393 const int ledW = !barSmooth ? (pdi.ledW + pdi.ledGap) : 1;
394 const int leds = (barSize + ledW - 1) / ledW;
395 const int ledMEnd = infoPtr->MarqueePos + MARQUEE_LEDS;
397 if (ledMEnd > leds)
399 /* case 1: the marquee bar extends over the end and wraps around to
400 * the start */
401 const int gapStart = max((ledMEnd - leds) * ledW, 0);
402 const int gapEnd = min(infoPtr->MarqueePos * ledW, barSize);
404 drawProcs[0]( &pdi, 0, gapStart);
405 drawProcs[1]( &pdi, gapStart, gapEnd);
406 drawProcs[0]( &pdi, gapEnd, barSize);
408 else
410 /* case 2: the marquee bar is between start and end */
411 const int barStart = infoPtr->MarqueePos * ledW;
412 const int barEnd = min (ledMEnd * ledW, barSize);
414 drawProcs[1]( &pdi, 0, barStart);
415 drawProcs[0]( &pdi, barStart, barEnd);
416 drawProcs[1]( &pdi, barEnd, barSize);
419 else
421 int barEnd = get_bar_position( infoPtr, dwStyle, &pdi.rect,
422 infoPtr->CurVal);
423 if (!barSmooth)
425 const int ledW = pdi.ledW + pdi.ledGap;
426 barEnd = min (((barEnd + ledW - 1) / ledW) * ledW, barSize);
428 drawProcs[0]( &pdi, 0, barEnd);
429 drawProcs[1]( &pdi, barEnd, barSize);
432 /* delete bar brush */
433 if (infoPtr->ColorBar != CLR_DEFAULT) DeleteObject (pdi.hbrBar);
434 if (infoPtr->ColorBk != CLR_DEFAULT) DeleteObject (pdi.hbrBk);
436 return 0;
439 /***********************************************************************
440 * PROGRESS_Paint
441 * Draw the progress bar. The background need not be erased.
442 * If dc!=0, it draws on it
444 static LRESULT PROGRESS_Paint (PROGRESS_INFO *infoPtr, HDC hdc)
446 PAINTSTRUCT ps;
447 if (hdc) return PROGRESS_Draw (infoPtr, hdc);
448 hdc = BeginPaint (infoPtr->Self, &ps);
449 PROGRESS_Draw (infoPtr, hdc);
450 EndPaint (infoPtr->Self, &ps);
451 return 0;
455 /***********************************************************************
456 * PROGRESS_Timer
457 * Handle the marquee timer messages
459 static LRESULT PROGRESS_Timer (PROGRESS_INFO *infoPtr, INT idTimer)
461 if(idTimer == ID_MARQUEE_TIMER)
463 LONG style = GetWindowLongW (infoPtr->Self, GWL_STYLE);
464 RECT rect;
465 int ledWidth, leds;
466 HTHEME theme = GetWindowTheme (infoPtr->Self);
467 BOOL barSmooth = (style & PBS_SMOOTH) && !theme;
469 get_client_rect (infoPtr->Self, &rect);
471 if(!barSmooth)
472 ledWidth = get_led_size( infoPtr, style, &rect ) +
473 get_led_gap( infoPtr );
474 else
475 ledWidth = 1;
477 leds = (get_bar_size( style, &rect ) + ledWidth - 1) /
478 ledWidth;
480 /* increment the marquee progress */
481 if(++infoPtr->MarqueePos >= leds)
483 infoPtr->MarqueePos = 0;
486 InvalidateRect(infoPtr->Self, &rect, FALSE);
487 UpdateWindow(infoPtr->Self);
489 return 0;
493 /***********************************************************************
494 * PROGRESS_CoercePos
495 * Makes sure the current position (CurVal) is within bounds.
497 static void PROGRESS_CoercePos(PROGRESS_INFO *infoPtr)
499 if(infoPtr->CurVal < infoPtr->MinVal)
500 infoPtr->CurVal = infoPtr->MinVal;
501 if(infoPtr->CurVal > infoPtr->MaxVal)
502 infoPtr->CurVal = infoPtr->MaxVal;
506 /***********************************************************************
507 * PROGRESS_SetFont
508 * Set new Font for progress bar
510 static HFONT PROGRESS_SetFont (PROGRESS_INFO *infoPtr, HFONT hFont, BOOL bRedraw)
512 HFONT hOldFont = infoPtr->Font;
513 infoPtr->Font = hFont;
514 /* Since infoPtr->Font is not used, there is no need for repaint */
515 return hOldFont;
518 static DWORD PROGRESS_SetRange (PROGRESS_INFO *infoPtr, int low, int high)
520 DWORD res = MAKELONG(LOWORD(infoPtr->MinVal), LOWORD(infoPtr->MaxVal));
522 /* if nothing changes, simply return */
523 if(infoPtr->MinVal == low && infoPtr->MaxVal == high) return res;
525 infoPtr->MinVal = low;
526 infoPtr->MaxVal = high;
527 PROGRESS_CoercePos(infoPtr);
528 InvalidateRect(infoPtr->Self, NULL, TRUE);
529 return res;
532 /***********************************************************************
533 * ProgressWindowProc
535 static LRESULT WINAPI ProgressWindowProc(HWND hwnd, UINT message,
536 WPARAM wParam, LPARAM lParam)
538 PROGRESS_INFO *infoPtr;
539 static const WCHAR themeClass[] = {'P','r','o','g','r','e','s','s',0};
540 HTHEME theme;
542 TRACE("hwnd=%p msg=%04x wparam=%lx lParam=%lx\n", hwnd, message, wParam, lParam);
544 infoPtr = (PROGRESS_INFO *)GetWindowLongPtrW(hwnd, 0);
546 if (!infoPtr && message != WM_CREATE)
547 return DefWindowProcW( hwnd, message, wParam, lParam );
549 switch(message) {
550 case WM_CREATE:
552 DWORD dwExStyle = GetWindowLongW (hwnd, GWL_EXSTYLE);
554 theme = OpenThemeData (hwnd, themeClass);
556 dwExStyle &= ~(WS_EX_CLIENTEDGE | WS_EX_WINDOWEDGE);
557 if (!theme) dwExStyle |= WS_EX_STATICEDGE;
558 SetWindowLongW (hwnd, GWL_EXSTYLE, dwExStyle);
559 /* Force recalculation of a non-client area */
560 SetWindowPos(hwnd, 0, 0, 0, 0, 0,
561 SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
563 /* allocate memory for info struct */
564 infoPtr = Alloc (sizeof(PROGRESS_INFO));
565 if (!infoPtr) return -1;
566 SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr);
568 /* initialize the info struct */
569 infoPtr->Self = hwnd;
570 infoPtr->MinVal = 0;
571 infoPtr->MaxVal = 100;
572 infoPtr->CurVal = 0;
573 infoPtr->Step = 10;
574 infoPtr->MarqueePos = 0;
575 infoPtr->Marquee = FALSE;
576 infoPtr->ColorBar = CLR_DEFAULT;
577 infoPtr->ColorBk = CLR_DEFAULT;
578 infoPtr->Font = 0;
580 TRACE("Progress Ctrl creation, hwnd=%p\n", hwnd);
581 return 0;
584 case WM_DESTROY:
585 TRACE("Progress Ctrl destruction, hwnd=%p\n", hwnd);
586 Free (infoPtr);
587 SetWindowLongPtrW(hwnd, 0, 0);
588 theme = GetWindowTheme (hwnd);
589 CloseThemeData (theme);
590 return 0;
592 case WM_ERASEBKGND:
593 return 1;
595 case WM_GETFONT:
596 return (LRESULT)infoPtr->Font;
598 case WM_SETFONT:
599 return (LRESULT)PROGRESS_SetFont(infoPtr, (HFONT)wParam, (BOOL)lParam);
601 case WM_PRINTCLIENT:
602 case WM_PAINT:
603 return PROGRESS_Paint (infoPtr, (HDC)wParam);
605 case WM_TIMER:
606 return PROGRESS_Timer (infoPtr, (INT)wParam);
608 case WM_THEMECHANGED:
610 DWORD dwExStyle = GetWindowLongW (hwnd, GWL_EXSTYLE);
612 theme = GetWindowTheme (hwnd);
613 CloseThemeData (theme);
614 theme = OpenThemeData (hwnd, themeClass);
616 /* WS_EX_STATICEDGE disappears when the control is themed */
617 if (theme)
618 dwExStyle &= ~WS_EX_STATICEDGE;
619 else
620 dwExStyle |= WS_EX_STATICEDGE;
621 SetWindowLongW (hwnd, GWL_EXSTYLE, dwExStyle);
623 InvalidateRect (hwnd, NULL, FALSE);
624 return 0;
627 case PBM_DELTAPOS:
629 INT oldVal;
630 oldVal = infoPtr->CurVal;
631 if(wParam != 0) {
632 infoPtr->CurVal += (INT)wParam;
633 PROGRESS_CoercePos (infoPtr);
634 TRACE("PBM_DELTAPOS: current pos changed from %d to %d\n", oldVal, infoPtr->CurVal);
635 PROGRESS_Invalidate( infoPtr, oldVal, infoPtr->CurVal );
636 UpdateWindow( infoPtr->Self );
638 return oldVal;
641 case PBM_SETPOS:
643 UINT oldVal;
644 oldVal = infoPtr->CurVal;
645 if(oldVal != wParam) {
646 infoPtr->CurVal = (INT)wParam;
647 PROGRESS_CoercePos(infoPtr);
648 TRACE("PBM_SETPOS: current pos changed from %d to %d\n", oldVal, infoPtr->CurVal);
649 PROGRESS_Invalidate( infoPtr, oldVal, infoPtr->CurVal );
650 UpdateWindow( infoPtr->Self );
652 return oldVal;
655 case PBM_SETRANGE:
656 return PROGRESS_SetRange (infoPtr, (int)LOWORD(lParam), (int)HIWORD(lParam));
658 case PBM_SETSTEP:
660 INT oldStep;
661 oldStep = infoPtr->Step;
662 infoPtr->Step = (INT)wParam;
663 return oldStep;
666 case PBM_STEPIT:
668 INT oldVal;
669 oldVal = infoPtr->CurVal;
670 infoPtr->CurVal += infoPtr->Step;
671 if(infoPtr->CurVal > infoPtr->MaxVal)
672 infoPtr->CurVal = infoPtr->MinVal;
673 if(oldVal != infoPtr->CurVal)
675 TRACE("PBM_STEPIT: current pos changed from %d to %d\n", oldVal, infoPtr->CurVal);
676 PROGRESS_Invalidate( infoPtr, oldVal, infoPtr->CurVal );
677 UpdateWindow( infoPtr->Self );
679 return oldVal;
682 case PBM_SETRANGE32:
683 return PROGRESS_SetRange (infoPtr, (int)wParam, (int)lParam);
685 case PBM_GETRANGE:
686 if (lParam) {
687 ((PPBRANGE)lParam)->iLow = infoPtr->MinVal;
688 ((PPBRANGE)lParam)->iHigh = infoPtr->MaxVal;
690 return wParam ? infoPtr->MinVal : infoPtr->MaxVal;
692 case PBM_GETPOS:
693 return infoPtr->CurVal;
695 case PBM_SETBARCOLOR:
696 infoPtr->ColorBar = (COLORREF)lParam;
697 InvalidateRect(hwnd, NULL, TRUE);
698 return 0;
700 case PBM_GETBARCOLOR:
701 return infoPtr->ColorBar;
703 case PBM_SETBKCOLOR:
704 infoPtr->ColorBk = (COLORREF)lParam;
705 InvalidateRect(hwnd, NULL, TRUE);
706 return 0;
708 case PBM_GETBKCOLOR:
709 return infoPtr->ColorBk;
711 case PBM_SETMARQUEE:
712 if(wParam != 0)
714 infoPtr->Marquee = TRUE;
715 SetTimer(infoPtr->Self, ID_MARQUEE_TIMER, (UINT)lParam, NULL);
717 else
719 infoPtr->Marquee = FALSE;
720 KillTimer(infoPtr->Self, ID_MARQUEE_TIMER);
722 return infoPtr->Marquee;
724 default:
725 if ((message >= WM_USER) && (message < WM_APP) && !COMCTL32_IsReflectedMessage(message))
726 ERR("unknown msg %04x wp=%04lx lp=%08lx\n", message, wParam, lParam );
727 return DefWindowProcW( hwnd, message, wParam, lParam );
732 /***********************************************************************
733 * PROGRESS_Register [Internal]
735 * Registers the progress bar window class.
737 void PROGRESS_Register (void)
739 WNDCLASSW wndClass;
741 ZeroMemory (&wndClass, sizeof(wndClass));
742 wndClass.style = CS_GLOBALCLASS | CS_VREDRAW | CS_HREDRAW;
743 wndClass.lpfnWndProc = (WNDPROC)ProgressWindowProc;
744 wndClass.cbClsExtra = 0;
745 wndClass.cbWndExtra = sizeof (PROGRESS_INFO *);
746 wndClass.hCursor = LoadCursorW (0, (LPWSTR)IDC_ARROW);
747 wndClass.lpszClassName = PROGRESS_CLASSW;
749 RegisterClassW (&wndClass);
753 /***********************************************************************
754 * PROGRESS_Unregister [Internal]
756 * Unregisters the progress bar window class.
758 void PROGRESS_Unregister (void)
760 UnregisterClassW (PROGRESS_CLASSW, NULL);