shell32/tests: Some tests for IShellWindows.
[wine.git] / dlls / comctl32 / progress.c
blob1b8fcf7211fc04f4923c851e5439b96bf7d5e813
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 * Styles:
33 * -- PBS_SMOOTHREVERSE
37 #include <stdarg.h>
38 #include <string.h>
39 #include "windef.h"
40 #include "winbase.h"
41 #include "wingdi.h"
42 #include "winuser.h"
43 #include "winnls.h"
44 #include "commctrl.h"
45 #include "comctl32.h"
46 #include "uxtheme.h"
47 #include "vssym32.h"
48 #include "wine/debug.h"
50 WINE_DEFAULT_DEBUG_CHANNEL(progress);
52 typedef struct
54 HWND Self; /* The window handle for this control */
55 INT CurVal; /* Current progress value */
56 INT MinVal; /* Minimum progress value */
57 INT MaxVal; /* Maximum progress value */
58 INT Step; /* Step to use on PMB_STEPIT */
59 INT MarqueePos; /* Marquee animation position */
60 BOOL Marquee; /* Whether the marquee animation is enabled */
61 COLORREF ColorBar; /* Bar color */
62 COLORREF ColorBk; /* Background color */
63 HFONT Font; /* Handle to font (not unused) */
64 } PROGRESS_INFO;
66 /* Control configuration constants */
68 #define LED_GAP 2
69 #define MARQUEE_LEDS 5
70 #define ID_MARQUEE_TIMER 1
71 #define DEFAULT_MARQUEE_PERIOD 30
73 /* Helper to obtain size of a progress bar chunk ("led"). */
74 static inline int get_led_size ( const PROGRESS_INFO *infoPtr, LONG style,
75 const RECT* rect )
77 HTHEME theme = GetWindowTheme (infoPtr->Self);
78 if (theme)
80 int chunkSize;
81 if (SUCCEEDED( GetThemeInt( theme, 0, 0, TMT_PROGRESSCHUNKSIZE, &chunkSize )))
82 return chunkSize;
85 if (style & PBS_VERTICAL)
86 return MulDiv (rect->right - rect->left, 2, 3);
87 else
88 return MulDiv (rect->bottom - rect->top, 2, 3);
91 /* Helper to obtain gap between progress bar chunks */
92 static inline int get_led_gap ( const PROGRESS_INFO *infoPtr )
94 HTHEME theme = GetWindowTheme (infoPtr->Self);
95 if (theme)
97 int spaceSize;
98 if (SUCCEEDED( GetThemeInt( theme, 0, 0, TMT_PROGRESSSPACESIZE, &spaceSize )))
99 return spaceSize;
102 return LED_GAP;
105 /* Get client rect. Takes into account that theming needs no adjustment. */
106 static inline void get_client_rect (HWND hwnd, RECT* rect)
108 HTHEME theme = GetWindowTheme (hwnd);
109 GetClientRect (hwnd, rect);
110 if (!theme)
111 InflateRect(rect, -1, -1);
112 else
114 DWORD dwStyle = GetWindowLongW (hwnd, GWL_STYLE);
115 int part = (dwStyle & PBS_VERTICAL) ? PP_BARVERT : PP_BAR;
116 GetThemeBackgroundContentRect (theme, 0, part, 0, rect, rect);
120 /* Compute the extend of the bar */
121 static inline int get_bar_size( LONG style, const RECT* rect )
123 if (style & PBS_VERTICAL)
124 return rect->bottom - rect->top;
125 else
126 return rect->right - rect->left;
129 /* Compute the pixel position of a progress value */
130 static inline int get_bar_position( const PROGRESS_INFO *infoPtr, LONG style,
131 const RECT* rect, INT value )
133 return MulDiv (value - infoPtr->MinVal, get_bar_size (style, rect),
134 infoPtr->MaxVal - infoPtr->MinVal);
137 /***********************************************************************
138 * PROGRESS_Invalidate
140 * Don't be too clever about invalidating the progress bar.
141 * InstallShield depends on this simple behaviour.
143 static void PROGRESS_Invalidate( const PROGRESS_INFO *infoPtr, INT old, INT new )
145 InvalidateRect( infoPtr->Self, NULL, old > new );
148 /* Information for a progress bar drawing helper */
149 typedef struct tagProgressDrawInfo
151 HDC hdc;
152 RECT rect;
153 HBRUSH hbrBar;
154 HBRUSH hbrBk;
155 int ledW, ledGap;
156 HTHEME theme;
157 RECT bgRect;
158 } ProgressDrawInfo;
160 typedef void (*ProgressDrawProc)(const ProgressDrawInfo* di, int start, int end);
162 /* draw solid horizontal bar from 'start' to 'end' */
163 static void draw_solid_bar_H (const ProgressDrawInfo* di, int start, int end)
165 RECT r;
166 r.left = di->rect.left + start;
167 r.top = di->rect.top;
168 r.right = di->rect.left + end;
169 r.bottom = di->rect.bottom;
170 FillRect (di->hdc, &r, di->hbrBar);
173 /* draw solid horizontal background from 'start' to 'end' */
174 static void draw_solid_bkg_H (const ProgressDrawInfo* di, int start, int end)
176 RECT r;
177 r.left = di->rect.left + start;
178 r.top = di->rect.top;
179 r.right = di->rect.left + end;
180 r.bottom = di->rect.bottom;
181 FillRect (di->hdc, &r, di->hbrBk);
184 /* draw solid vertical bar from 'start' to 'end' */
185 static void draw_solid_bar_V (const ProgressDrawInfo* di, int start, int end)
187 RECT r;
188 r.left = di->rect.left;
189 r.top = di->rect.bottom - end;
190 r.right = di->rect.right;
191 r.bottom = di->rect.bottom - start;
192 FillRect (di->hdc, &r, di->hbrBar);
195 /* draw solid vertical background from 'start' to 'end' */
196 static void draw_solid_bkg_V (const ProgressDrawInfo* di, int start, int end)
198 RECT r;
199 r.left = di->rect.left;
200 r.top = di->rect.bottom - end;
201 r.right = di->rect.right;
202 r.bottom = di->rect.bottom - start;
203 FillRect (di->hdc, &r, di->hbrBk);
206 /* draw chunky horizontal bar from 'start' to 'end' */
207 static void draw_chunk_bar_H (const ProgressDrawInfo* di, int start, int end)
209 RECT r;
210 int right = di->rect.left + end;
211 r.left = di->rect.left + start;
212 r.top = di->rect.top;
213 r.bottom = di->rect.bottom;
214 while (r.left < right)
216 r.right = min (r.left + di->ledW, right);
217 FillRect (di->hdc, &r, di->hbrBar);
218 r.left = r.right;
219 r.right = min (r.left + di->ledGap, right);
220 FillRect (di->hdc, &r, di->hbrBk);
221 r.left = r.right;
225 /* draw chunky vertical bar from 'start' to 'end' */
226 static void draw_chunk_bar_V (const ProgressDrawInfo* di, int start, int end)
228 RECT r;
229 int top = di->rect.bottom - end;
230 r.left = di->rect.left;
231 r.right = di->rect.right;
232 r.bottom = di->rect.bottom - start;
233 while (r.bottom > top)
235 r.top = max (r.bottom - di->ledW, top);
236 FillRect (di->hdc, &r, di->hbrBar);
237 r.bottom = r.top;
238 r.top = max (r.bottom - di->ledGap, top);
239 FillRect (di->hdc, &r, di->hbrBk);
240 r.bottom = r.top;
244 /* drawing functions for "classic" style */
245 static const ProgressDrawProc drawProcClassic[8] = {
246 /* Smooth */
247 /* Horizontal */
248 draw_solid_bar_H, draw_solid_bkg_H,
249 /* Vertical */
250 draw_solid_bar_V, draw_solid_bkg_V,
251 /* Chunky */
252 /* Horizontal */
253 draw_chunk_bar_H, draw_solid_bkg_H,
254 /* Vertical */
255 draw_chunk_bar_V, draw_solid_bkg_V,
258 /* draw themed horizontal bar from 'start' to 'end' */
259 static void draw_theme_bar_H (const ProgressDrawInfo* di, int start, int end)
261 RECT r;
262 r.left = di->rect.left + start;
263 r.top = di->rect.top;
264 r.bottom = di->rect.bottom;
265 r.right = di->rect.left + end;
266 DrawThemeBackground (di->theme, di->hdc, PP_CHUNK, 0, &r, NULL);
269 /* draw themed vertical bar from 'start' to 'end' */
270 static void draw_theme_bar_V (const ProgressDrawInfo* di, int start, int end)
272 RECT r;
273 r.left = di->rect.left;
274 r.right = di->rect.right;
275 r.bottom = di->rect.bottom - start;
276 r.top = di->rect.bottom - end;
277 DrawThemeBackground (di->theme, di->hdc, PP_CHUNKVERT, 0, &r, NULL);
280 /* draw themed horizontal background from 'start' to 'end' */
281 static void draw_theme_bkg_H (const ProgressDrawInfo* di, int start, int end)
283 RECT bgrect, r;
285 r.left = di->rect.left + start;
286 r.top = di->rect.top;
287 r.right = di->rect.left + end;
288 r.bottom = di->rect.bottom;
290 bgrect = di->bgRect;
291 OffsetRect(&bgrect, -bgrect.left, -bgrect.top);
293 DrawThemeBackground (di->theme, di->hdc, PP_BAR, 0, &bgrect, &r);
296 /* draw themed vertical background from 'start' to 'end' */
297 static void draw_theme_bkg_V (const ProgressDrawInfo* di, int start, int end)
299 RECT bgrect, r;
301 r.left = di->rect.left;
302 r.top = di->rect.bottom - end;
303 r.right = di->rect.right;
304 r.bottom = di->rect.bottom - start;
306 bgrect = di->bgRect;
307 OffsetRect(&bgrect, -bgrect.left, -bgrect.top);
309 DrawThemeBackground (di->theme, di->hdc, PP_BARVERT, 0, &bgrect, &r);
312 /* drawing functions for themed style */
313 static const ProgressDrawProc drawProcThemed[8] = {
314 /* Smooth */
315 /* Horizontal */
316 draw_theme_bar_H, draw_theme_bkg_H,
317 /* Vertical */
318 draw_theme_bar_V, draw_theme_bkg_V,
319 /* Chunky */
320 /* Horizontal */
321 draw_theme_bar_H, draw_theme_bkg_H,
322 /* Vertical */
323 draw_theme_bar_V, draw_theme_bkg_V,
326 /***********************************************************************
327 * PROGRESS_Draw
328 * Draws the progress bar.
330 static LRESULT PROGRESS_Draw (PROGRESS_INFO *infoPtr, HDC hdc)
332 int barSize;
333 DWORD dwStyle;
334 BOOL barSmooth;
335 const ProgressDrawProc* drawProcs;
336 ProgressDrawInfo pdi;
338 TRACE("(infoPtr=%p, hdc=%p)\n", infoPtr, hdc);
340 pdi.hdc = hdc;
341 pdi.theme = GetWindowTheme (infoPtr->Self);
343 /* get the required bar brush */
344 if (infoPtr->ColorBar == CLR_DEFAULT)
345 pdi.hbrBar = GetSysColorBrush(COLOR_HIGHLIGHT);
346 else
347 pdi.hbrBar = CreateSolidBrush (infoPtr->ColorBar);
349 if (infoPtr->ColorBk == CLR_DEFAULT)
350 pdi.hbrBk = GetSysColorBrush(COLOR_3DFACE);
351 else
352 pdi.hbrBk = CreateSolidBrush(infoPtr->ColorBk);
354 /* get the window style */
355 dwStyle = GetWindowLongW (infoPtr->Self, GWL_STYLE);
357 /* get client rectangle */
358 GetClientRect (infoPtr->Self, &pdi.rect);
359 if (!pdi.theme) {
360 FrameRect( hdc, &pdi.rect, pdi.hbrBk );
361 InflateRect(&pdi.rect, -1, -1);
363 else
365 RECT cntRect;
366 int part = (dwStyle & PBS_VERTICAL) ? PP_BARVERT : PP_BAR;
368 GetThemeBackgroundContentRect (pdi.theme, hdc, part, 0, &pdi.rect,
369 &cntRect);
371 /* Exclude content rect - content background will be drawn later */
372 ExcludeClipRect (hdc, cntRect.left, cntRect.top,
373 cntRect.right, cntRect.bottom);
374 if (IsThemeBackgroundPartiallyTransparent (pdi.theme, part, 0))
375 DrawThemeParentBackground (infoPtr->Self, hdc, NULL);
376 DrawThemeBackground (pdi.theme, hdc, part, 0, &pdi.rect, NULL);
377 SelectClipRgn (hdc, NULL);
378 CopyRect (&pdi.rect, &cntRect);
381 /* compute some drawing parameters */
382 barSmooth = (dwStyle & PBS_SMOOTH) && !pdi.theme;
383 drawProcs = &((pdi.theme ? drawProcThemed : drawProcClassic)[(barSmooth ? 0 : 4)
384 + ((dwStyle & PBS_VERTICAL) ? 2 : 0)]);
385 barSize = get_bar_size( dwStyle, &pdi.rect );
386 if (pdi.theme)
388 GetWindowRect( infoPtr->Self, &pdi.bgRect );
389 MapWindowPoints( infoPtr->Self, 0, (POINT*)&pdi.bgRect, 2 );
392 if (!barSmooth)
393 pdi.ledW = get_led_size( infoPtr, dwStyle, &pdi.rect);
394 pdi.ledGap = get_led_gap( infoPtr );
396 if (dwStyle & PBS_MARQUEE)
398 const int ledW = !barSmooth ? (pdi.ledW + pdi.ledGap) : 1;
399 const int leds = (barSize + ledW - 1) / ledW;
400 const int ledMEnd = infoPtr->MarqueePos + MARQUEE_LEDS;
402 if (ledMEnd > leds)
404 /* case 1: the marquee bar extends over the end and wraps around to
405 * the start */
406 const int gapStart = max((ledMEnd - leds) * ledW, 0);
407 const int gapEnd = min(infoPtr->MarqueePos * ledW, barSize);
409 drawProcs[0]( &pdi, 0, gapStart);
410 drawProcs[1]( &pdi, gapStart, gapEnd);
411 drawProcs[0]( &pdi, gapEnd, barSize);
413 else
415 /* case 2: the marquee bar is between start and end */
416 const int barStart = infoPtr->MarqueePos * ledW;
417 const int barEnd = min (ledMEnd * ledW, barSize);
419 drawProcs[1]( &pdi, 0, barStart);
420 drawProcs[0]( &pdi, barStart, barEnd);
421 drawProcs[1]( &pdi, barEnd, barSize);
424 else
426 int barEnd = get_bar_position( infoPtr, dwStyle, &pdi.rect,
427 infoPtr->CurVal);
428 if (!barSmooth)
430 const int ledW = pdi.ledW + pdi.ledGap;
431 barEnd = min (((barEnd + ledW - 1) / ledW) * ledW, barSize);
433 drawProcs[0]( &pdi, 0, barEnd);
434 drawProcs[1]( &pdi, barEnd, barSize);
437 /* delete bar brush */
438 if (infoPtr->ColorBar != CLR_DEFAULT) DeleteObject (pdi.hbrBar);
439 if (infoPtr->ColorBk != CLR_DEFAULT) DeleteObject (pdi.hbrBk);
441 return 0;
444 /***********************************************************************
445 * PROGRESS_Paint
446 * Draw the progress bar. The background need not be erased.
447 * If dc!=0, it draws on it
449 static LRESULT PROGRESS_Paint (PROGRESS_INFO *infoPtr, HDC hdc)
451 PAINTSTRUCT ps;
452 if (hdc) return PROGRESS_Draw (infoPtr, hdc);
453 hdc = BeginPaint (infoPtr->Self, &ps);
454 PROGRESS_Draw (infoPtr, hdc);
455 EndPaint (infoPtr->Self, &ps);
456 return 0;
460 /***********************************************************************
461 * Advance marquee progress by one step.
463 static void PROGRESS_UpdateMarquee (PROGRESS_INFO *infoPtr)
465 LONG style = GetWindowLongW (infoPtr->Self, GWL_STYLE);
466 RECT rect;
467 int ledWidth, leds;
468 HTHEME theme = GetWindowTheme (infoPtr->Self);
469 BOOL smooth = (style & PBS_SMOOTH) && !theme;
471 get_client_rect (infoPtr->Self, &rect);
473 if (smooth)
474 ledWidth = 1;
475 else
476 ledWidth = get_led_size( infoPtr, style, &rect ) + get_led_gap( infoPtr );
478 leds = (get_bar_size( style, &rect ) + ledWidth - 1) /
479 ledWidth;
481 /* increment the marquee progress */
482 if (++infoPtr->MarqueePos >= leds)
483 infoPtr->MarqueePos = 0;
485 InvalidateRect(infoPtr->Self, &rect, TRUE);
486 UpdateWindow(infoPtr->Self);
490 /***********************************************************************
491 * PROGRESS_CoercePos
492 * Makes sure the current position (CurVal) is within bounds.
494 static void PROGRESS_CoercePos(PROGRESS_INFO *infoPtr)
496 if(infoPtr->CurVal < infoPtr->MinVal)
497 infoPtr->CurVal = infoPtr->MinVal;
498 if(infoPtr->CurVal > infoPtr->MaxVal)
499 infoPtr->CurVal = infoPtr->MaxVal;
503 /***********************************************************************
504 * PROGRESS_SetFont
505 * Set new Font for progress bar
507 static HFONT PROGRESS_SetFont (PROGRESS_INFO *infoPtr, HFONT hFont, BOOL bRedraw)
509 HFONT hOldFont = infoPtr->Font;
510 infoPtr->Font = hFont;
511 /* Since infoPtr->Font is not used, there is no need for repaint */
512 return hOldFont;
515 static DWORD PROGRESS_SetRange (PROGRESS_INFO *infoPtr, int low, int high)
517 DWORD res = MAKELONG(LOWORD(infoPtr->MinVal), LOWORD(infoPtr->MaxVal));
519 /* if nothing changes, simply return */
520 if(infoPtr->MinVal == low && infoPtr->MaxVal == high) return res;
522 infoPtr->MinVal = low;
523 infoPtr->MaxVal = high;
524 PROGRESS_CoercePos(infoPtr);
525 InvalidateRect(infoPtr->Self, NULL, TRUE);
526 return res;
529 static UINT PROGRESS_SetPos (PROGRESS_INFO *infoPtr, INT pos)
531 DWORD style = GetWindowLongW(infoPtr->Self, GWL_STYLE);
533 if (style & PBS_MARQUEE)
535 PROGRESS_UpdateMarquee(infoPtr);
536 return 1;
538 else
540 UINT oldVal;
541 oldVal = infoPtr->CurVal;
542 if (oldVal != pos) {
543 infoPtr->CurVal = pos;
544 PROGRESS_CoercePos(infoPtr);
545 TRACE("PBM_SETPOS: current pos changed from %d to %d\n", oldVal, infoPtr->CurVal);
546 PROGRESS_Invalidate( infoPtr, oldVal, infoPtr->CurVal );
547 UpdateWindow( infoPtr->Self );
549 return oldVal;
553 /***********************************************************************
554 * ProgressWindowProc
556 static LRESULT WINAPI ProgressWindowProc(HWND hwnd, UINT message,
557 WPARAM wParam, LPARAM lParam)
559 PROGRESS_INFO *infoPtr;
560 static const WCHAR themeClass[] = {'P','r','o','g','r','e','s','s',0};
561 HTHEME theme;
563 TRACE("hwnd=%p msg=%04x wparam=%lx lParam=%lx\n", hwnd, message, wParam, lParam);
565 infoPtr = (PROGRESS_INFO *)GetWindowLongPtrW(hwnd, 0);
567 if (!infoPtr && message != WM_CREATE)
568 return DefWindowProcW( hwnd, message, wParam, lParam );
570 switch(message) {
571 case WM_CREATE:
573 DWORD dwExStyle = GetWindowLongW (hwnd, GWL_EXSTYLE);
575 theme = OpenThemeData (hwnd, themeClass);
577 dwExStyle &= ~(WS_EX_CLIENTEDGE | WS_EX_WINDOWEDGE);
578 if (!theme) dwExStyle |= WS_EX_STATICEDGE;
579 SetWindowLongW (hwnd, GWL_EXSTYLE, dwExStyle);
580 /* Force recalculation of a non-client area */
581 SetWindowPos(hwnd, 0, 0, 0, 0, 0,
582 SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
584 /* allocate memory for info struct */
585 infoPtr = Alloc (sizeof(PROGRESS_INFO));
586 if (!infoPtr) return -1;
587 SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr);
589 /* initialize the info struct */
590 infoPtr->Self = hwnd;
591 infoPtr->MinVal = 0;
592 infoPtr->MaxVal = 100;
593 infoPtr->CurVal = 0;
594 infoPtr->Step = 10;
595 infoPtr->MarqueePos = 0;
596 infoPtr->Marquee = FALSE;
597 infoPtr->ColorBar = CLR_DEFAULT;
598 infoPtr->ColorBk = CLR_DEFAULT;
599 infoPtr->Font = 0;
601 TRACE("Progress Ctrl creation, hwnd=%p\n", hwnd);
602 return 0;
605 case WM_DESTROY:
606 TRACE("Progress Ctrl destruction, hwnd=%p\n", hwnd);
607 Free (infoPtr);
608 SetWindowLongPtrW(hwnd, 0, 0);
609 theme = GetWindowTheme (hwnd);
610 CloseThemeData (theme);
611 return 0;
613 case WM_ERASEBKGND:
614 return 1;
616 case WM_GETFONT:
617 return (LRESULT)infoPtr->Font;
619 case WM_SETFONT:
620 return (LRESULT)PROGRESS_SetFont(infoPtr, (HFONT)wParam, (BOOL)lParam);
622 case WM_PRINTCLIENT:
623 case WM_PAINT:
624 return PROGRESS_Paint (infoPtr, (HDC)wParam);
626 case WM_TIMER:
627 if (wParam == ID_MARQUEE_TIMER)
628 PROGRESS_UpdateMarquee (infoPtr);
629 return 0;
631 case WM_THEMECHANGED:
633 DWORD dwExStyle = GetWindowLongW (hwnd, GWL_EXSTYLE);
635 theme = GetWindowTheme (hwnd);
636 CloseThemeData (theme);
637 theme = OpenThemeData (hwnd, themeClass);
639 /* WS_EX_STATICEDGE disappears when the control is themed */
640 if (theme)
641 dwExStyle &= ~WS_EX_STATICEDGE;
642 else
643 dwExStyle |= WS_EX_STATICEDGE;
644 SetWindowLongW (hwnd, GWL_EXSTYLE, dwExStyle);
646 InvalidateRect (hwnd, NULL, FALSE);
647 return 0;
650 case PBM_DELTAPOS:
652 INT oldVal;
653 oldVal = infoPtr->CurVal;
654 if(wParam != 0) {
655 infoPtr->CurVal += (INT)wParam;
656 PROGRESS_CoercePos (infoPtr);
657 TRACE("PBM_DELTAPOS: current pos changed from %d to %d\n", oldVal, infoPtr->CurVal);
658 PROGRESS_Invalidate( infoPtr, oldVal, infoPtr->CurVal );
659 UpdateWindow( infoPtr->Self );
661 return oldVal;
664 case PBM_SETPOS:
665 return PROGRESS_SetPos(infoPtr, wParam);
667 case PBM_SETRANGE:
668 return PROGRESS_SetRange (infoPtr, (int)LOWORD(lParam), (int)HIWORD(lParam));
670 case PBM_SETSTEP:
672 INT oldStep;
673 oldStep = infoPtr->Step;
674 infoPtr->Step = (INT)wParam;
675 return oldStep;
678 case PBM_GETSTEP:
679 return infoPtr->Step;
681 case PBM_STEPIT:
683 INT oldVal;
684 oldVal = infoPtr->CurVal;
685 infoPtr->CurVal += infoPtr->Step;
686 if(infoPtr->CurVal > infoPtr->MaxVal)
687 infoPtr->CurVal = infoPtr->MinVal;
688 if(oldVal != infoPtr->CurVal)
690 TRACE("PBM_STEPIT: current pos changed from %d to %d\n", oldVal, infoPtr->CurVal);
691 PROGRESS_Invalidate( infoPtr, oldVal, infoPtr->CurVal );
692 UpdateWindow( infoPtr->Self );
694 return oldVal;
697 case PBM_SETRANGE32:
698 return PROGRESS_SetRange (infoPtr, (int)wParam, (int)lParam);
700 case PBM_GETRANGE:
701 if (lParam) {
702 ((PPBRANGE)lParam)->iLow = infoPtr->MinVal;
703 ((PPBRANGE)lParam)->iHigh = infoPtr->MaxVal;
705 return wParam ? infoPtr->MinVal : infoPtr->MaxVal;
707 case PBM_GETPOS:
708 return infoPtr->CurVal;
710 case PBM_SETBARCOLOR:
712 COLORREF clr = infoPtr->ColorBar;
714 infoPtr->ColorBar = (COLORREF)lParam;
715 InvalidateRect(hwnd, NULL, TRUE);
716 return clr;
719 case PBM_GETBARCOLOR:
720 return infoPtr->ColorBar;
722 case PBM_SETBKCOLOR:
724 COLORREF clr = infoPtr->ColorBk;
726 infoPtr->ColorBk = (COLORREF)lParam;
727 InvalidateRect(hwnd, NULL, TRUE);
728 return clr;
731 case PBM_GETBKCOLOR:
732 return infoPtr->ColorBk;
734 case PBM_SETSTATE:
735 if(wParam != PBST_NORMAL)
736 FIXME("state %04lx not yet handled\n", wParam);
737 return PBST_NORMAL;
739 case PBM_GETSTATE:
740 return PBST_NORMAL;
742 case PBM_SETMARQUEE:
743 if(wParam != 0)
745 UINT period = lParam ? (UINT)lParam : DEFAULT_MARQUEE_PERIOD;
746 infoPtr->Marquee = TRUE;
747 SetTimer(infoPtr->Self, ID_MARQUEE_TIMER, period, NULL);
749 else
751 infoPtr->Marquee = FALSE;
752 KillTimer(infoPtr->Self, ID_MARQUEE_TIMER);
754 return infoPtr->Marquee;
756 default:
757 if ((message >= WM_USER) && (message < WM_APP) && !COMCTL32_IsReflectedMessage(message))
758 ERR("unknown msg %04x wp=%04lx lp=%08lx\n", message, wParam, lParam );
759 return DefWindowProcW( hwnd, message, wParam, lParam );
764 /***********************************************************************
765 * PROGRESS_Register [Internal]
767 * Registers the progress bar window class.
769 void PROGRESS_Register (void)
771 WNDCLASSW wndClass;
773 ZeroMemory (&wndClass, sizeof(wndClass));
774 wndClass.style = CS_GLOBALCLASS | CS_VREDRAW | CS_HREDRAW;
775 wndClass.lpfnWndProc = ProgressWindowProc;
776 wndClass.cbClsExtra = 0;
777 wndClass.cbWndExtra = sizeof (PROGRESS_INFO *);
778 wndClass.hCursor = LoadCursorW (0, (LPWSTR)IDC_ARROW);
779 wndClass.lpszClassName = PROGRESS_CLASSW;
781 RegisterClassW (&wndClass);
785 /***********************************************************************
786 * PROGRESS_Unregister [Internal]
788 * Unregisters the progress bar window class.
790 void PROGRESS_Unregister (void)
792 UnregisterClassW (PROGRESS_CLASSW, NULL);