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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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.
43 #include "wine/debug.h"
45 WINE_DEFAULT_DEBUG_CHANNEL(progress
);
49 HWND Self
; /* The window handle for this control */
50 INT CurVal
; /* Current progress value */
51 INT MinVal
; /* Minimum progress value */
52 INT MaxVal
; /* Maximum progress value */
53 INT Step
; /* Step to use on PMB_STEPIT */
54 INT MarqueePos
; /* Marquee animation position */
55 BOOL Marquee
; /* Whether the marquee animation is enabled */
56 COLORREF ColorBar
; /* Bar color */
57 COLORREF ColorBk
; /* Background color */
58 HFONT Font
; /* Handle to font (not unused) */
61 /* Control configuration constants */
64 #define MARQUEE_LEDS 5
65 #define ID_MARQUEE_TIMER 1
67 /* Helper to obtain size of a progress bar chunk ("led"). */
68 static inline int get_led_size ( PROGRESS_INFO
*infoPtr
, LONG style
,
71 HTHEME theme
= GetWindowTheme (infoPtr
->Self
);
75 if (SUCCEEDED( GetThemeInt( theme
, 0, 0, TMT_PROGRESSCHUNKSIZE
, &chunkSize
)))
79 if (style
& PBS_VERTICAL
)
80 return MulDiv (rect
->right
- rect
->left
, 2, 3);
82 return MulDiv (rect
->bottom
- rect
->top
, 2, 3);
85 /* Helper to obtain gap between progress bar chunks */
86 static inline int get_led_gap ( PROGRESS_INFO
*infoPtr
)
88 HTHEME theme
= GetWindowTheme (infoPtr
->Self
);
92 if (SUCCEEDED( GetThemeInt( theme
, 0, 0, TMT_PROGRESSSPACESIZE
, &spaceSize
)))
99 /* Get client rect. Takes into account that theming needs no adjustment. */
100 static inline void get_client_rect (HWND hwnd
, RECT
* rect
)
102 HTHEME theme
= GetWindowTheme (hwnd
);
103 GetClientRect (hwnd
, rect
);
105 InflateRect(rect
, -1, -1);
108 DWORD dwStyle
= GetWindowLongW (hwnd
, GWL_STYLE
);
109 int part
= (dwStyle
& PBS_VERTICAL
) ? PP_BARVERT
: PP_BAR
;
110 GetThemeBackgroundContentRect (theme
, 0, part
, 0, rect
, rect
);
114 /* Compute the extend of the bar */
115 static inline int get_bar_size( LONG style
, const RECT
* rect
)
117 if (style
& PBS_VERTICAL
)
118 return rect
->bottom
- rect
->top
;
120 return rect
->right
- rect
->left
;
123 /* Compute the pixel position of a progress value */
124 static inline int get_bar_position( PROGRESS_INFO
*infoPtr
, LONG style
,
125 const RECT
* rect
, INT value
)
127 return MulDiv (value
- infoPtr
->MinVal
, get_bar_size (style
, rect
),
128 infoPtr
->MaxVal
- infoPtr
->MinVal
);
131 /***********************************************************************
132 * PROGRESS_Invalidate
134 * Invalide the range between old and new pos.
136 static void PROGRESS_Invalidate( PROGRESS_INFO
*infoPtr
, INT old
, INT
new )
138 LONG style
= GetWindowLongW (infoPtr
->Self
, GWL_STYLE
);
141 BOOL barSmooth
= (style
& PBS_SMOOTH
) && !GetWindowTheme (infoPtr
->Self
);
143 get_client_rect( infoPtr
->Self
, &rect
);
145 oldPos
= get_bar_position( infoPtr
, style
, &rect
, old
);
146 newPos
= get_bar_position( infoPtr
, style
, &rect
, new );
148 if (style
& PBS_VERTICAL
)
150 rect
.top
= rect
.bottom
- max( oldPos
, newPos
);
151 rect
.bottom
= rect
.bottom
- min( oldPos
, newPos
);
152 if (!barSmooth
) rect
.top
-=
153 get_led_size (infoPtr
, style
, &rect
) + get_led_gap (infoPtr
);
157 rect
.left
= min( oldPos
, newPos
);
158 rect
.right
= max( oldPos
, newPos
);
159 if (!barSmooth
) rect
.right
+=
160 get_led_size (infoPtr
, style
, &rect
) + get_led_gap (infoPtr
);
162 InvalidateRect( infoPtr
->Self
, &rect
, oldPos
> newPos
);
165 /* Information for a progress bar drawing helper */
166 typedef struct tagProgressDrawInfo
177 typedef void (*ProgressDrawProc
)(const ProgressDrawInfo
* di
, int start
, int end
);
179 /* draw solid horizontal bar from 'start' to 'end' */
180 static void draw_solid_bar_H (const ProgressDrawInfo
* di
, int start
, int end
)
183 r
.left
= di
->rect
.left
+ start
;
184 r
.top
= di
->rect
.top
;
185 r
.right
= di
->rect
.left
+ end
;
186 r
.bottom
= di
->rect
.bottom
;
187 FillRect (di
->hdc
, &r
, di
->hbrBar
);
190 /* draw solid horizontal background from 'start' to 'end' */
191 static void draw_solid_bkg_H (const ProgressDrawInfo
* di
, int start
, int end
)
194 r
.left
= di
->rect
.left
+ start
;
195 r
.top
= di
->rect
.top
;
196 r
.right
= di
->rect
.left
+ end
;
197 r
.bottom
= di
->rect
.bottom
;
198 FillRect (di
->hdc
, &r
, di
->hbrBk
);
201 /* draw solid vertical bar from 'start' to 'end' */
202 static void draw_solid_bar_V (const ProgressDrawInfo
* di
, int start
, int end
)
205 r
.left
= di
->rect
.left
;
206 r
.top
= di
->rect
.bottom
- end
;
207 r
.right
= di
->rect
.right
;
208 r
.bottom
= di
->rect
.bottom
- start
;
209 FillRect (di
->hdc
, &r
, di
->hbrBar
);
212 /* draw solid vertical background from 'start' to 'end' */
213 static void draw_solid_bkg_V (const ProgressDrawInfo
* di
, int start
, int end
)
216 r
.left
= di
->rect
.left
;
217 r
.top
= di
->rect
.bottom
- end
;
218 r
.right
= di
->rect
.right
;
219 r
.bottom
= di
->rect
.bottom
- start
;
220 FillRect (di
->hdc
, &r
, di
->hbrBk
);
223 /* draw chunky horizontal bar from 'start' to 'end' */
224 static void draw_chunk_bar_H (const ProgressDrawInfo
* di
, int start
, int end
)
227 int right
= di
->rect
.left
+ end
;
228 r
.left
= di
->rect
.left
+ start
;
229 r
.top
= di
->rect
.top
;
230 r
.bottom
= di
->rect
.bottom
;
231 while (r
.left
< right
)
233 r
.right
= min (r
.left
+ di
->ledW
, right
);
234 FillRect (di
->hdc
, &r
, di
->hbrBar
);
236 r
.right
= min (r
.left
+ di
->ledGap
, right
);
237 FillRect (di
->hdc
, &r
, di
->hbrBk
);
242 /* draw chunky vertical bar from 'start' to 'end' */
243 static void draw_chunk_bar_V (const ProgressDrawInfo
* di
, int start
, int end
)
246 int top
= di
->rect
.bottom
- end
;
247 r
.left
= di
->rect
.left
;
248 r
.right
= di
->rect
.right
;
249 r
.bottom
= di
->rect
.bottom
- start
;
250 while (r
.bottom
> top
)
252 r
.top
= max (r
.bottom
- di
->ledW
, top
);
253 FillRect (di
->hdc
, &r
, di
->hbrBar
);
255 r
.top
= max (r
.bottom
- di
->ledGap
, top
);
256 FillRect (di
->hdc
, &r
, di
->hbrBk
);
261 /* drawing functions for "classic" style */
262 static const ProgressDrawProc drawProcClassic
[8] = {
265 draw_solid_bar_H
, draw_solid_bkg_H
,
267 draw_solid_bar_V
, draw_solid_bkg_V
,
270 draw_chunk_bar_H
, draw_solid_bkg_H
,
272 draw_chunk_bar_V
, draw_solid_bkg_V
,
275 /* draw themed horizontal bar from 'start' to 'end' */
276 static void draw_theme_bar_H (const ProgressDrawInfo
* di
, int start
, int end
)
279 int right
= di
->rect
.left
+ end
;
280 r
.left
= di
->rect
.left
+ start
;
281 r
.top
= di
->rect
.top
;
282 r
.bottom
= di
->rect
.bottom
;
283 while (r
.left
< right
)
285 r
.right
= min (r
.left
+ di
->ledW
, right
);
286 DrawThemeBackground (di
->theme
, di
->hdc
, PP_CHUNK
, 0, &r
, NULL
);
288 r
.right
= min (r
.left
+ di
->ledGap
, right
);
289 DrawThemeBackground (di
->theme
, di
->hdc
, PP_BAR
, 0, &di
->bgRect
, &r
);
294 /* draw themed horizontal bar from 'start' to 'end' */
295 static void draw_theme_bar_V (const ProgressDrawInfo
* di
, int start
, int end
)
298 int top
= di
->rect
.bottom
- end
;
299 r
.left
= di
->rect
.left
;
300 r
.right
= di
->rect
.right
;
301 r
.bottom
= di
->rect
.bottom
- start
;
302 while (r
.bottom
> top
)
304 r
.top
= max (r
.bottom
- di
->ledW
, top
);
305 DrawThemeBackground (di
->theme
, di
->hdc
, PP_CHUNKVERT
, 0, &r
, NULL
);
307 r
.top
= max (r
.bottom
- di
->ledGap
, top
);
308 DrawThemeBackground (di
->theme
, di
->hdc
, PP_BARVERT
, 0, &di
->bgRect
, &r
);
313 /* draw themed horizontal background from 'start' to 'end' */
314 static void draw_theme_bkg_H (const ProgressDrawInfo
* di
, int start
, int end
)
317 r
.left
= di
->rect
.left
+ start
;
318 r
.top
= di
->rect
.top
;
319 r
.right
= di
->rect
.left
+ end
;
320 r
.bottom
= di
->rect
.bottom
;
321 DrawThemeBackground (di
->theme
, di
->hdc
, PP_BAR
, 0, &di
->bgRect
, &r
);
324 /* draw themed vertical background from 'start' to 'end' */
325 static void draw_theme_bkg_V (const ProgressDrawInfo
* di
, int start
, int end
)
328 r
.left
= di
->rect
.left
;
329 r
.top
= di
->rect
.bottom
- end
;
330 r
.right
= di
->rect
.right
;
331 r
.bottom
= di
->rect
.bottom
- start
;
332 DrawThemeBackground (di
->theme
, di
->hdc
, PP_BARVERT
, 0, &di
->bgRect
, &r
);
335 /* drawing functions for themed style */
336 static const ProgressDrawProc drawProcThemed
[8] = {
339 draw_theme_bar_H
, draw_theme_bkg_H
,
341 draw_theme_bar_V
, draw_theme_bkg_V
,
344 draw_theme_bar_H
, draw_theme_bkg_H
,
346 draw_theme_bar_V
, draw_theme_bkg_V
,
349 /***********************************************************************
351 * Draws the progress bar.
353 static LRESULT
PROGRESS_Draw (PROGRESS_INFO
*infoPtr
, HDC hdc
)
358 const ProgressDrawProc
* drawProcs
;
359 ProgressDrawInfo pdi
;
361 TRACE("(infoPtr=%p, hdc=%p)\n", infoPtr
, hdc
);
364 pdi
.theme
= GetWindowTheme (infoPtr
->Self
);
366 /* get the required bar brush */
367 if (infoPtr
->ColorBar
== CLR_DEFAULT
)
368 pdi
.hbrBar
= GetSysColorBrush(COLOR_HIGHLIGHT
);
370 pdi
.hbrBar
= CreateSolidBrush (infoPtr
->ColorBar
);
372 if (infoPtr
->ColorBk
== CLR_DEFAULT
)
373 pdi
.hbrBk
= GetSysColorBrush(COLOR_3DFACE
);
375 pdi
.hbrBk
= CreateSolidBrush(infoPtr
->ColorBk
);
377 /* get the window style */
378 dwStyle
= GetWindowLongW (infoPtr
->Self
, GWL_STYLE
);
380 /* get client rectangle */
381 GetClientRect (infoPtr
->Self
, &pdi
.rect
);
383 FrameRect( hdc
, &pdi
.rect
, pdi
.hbrBk
);
384 InflateRect(&pdi
.rect
, -1, -1);
389 int part
= (dwStyle
& PBS_VERTICAL
) ? PP_BARVERT
: PP_BAR
;
391 GetThemeBackgroundContentRect (pdi
.theme
, hdc
, part
, 0, &pdi
.rect
,
394 /* Exclude content rect - content background will be drawn later */
395 ExcludeClipRect (hdc
, cntRect
.left
, cntRect
.top
,
396 cntRect
.right
, cntRect
.bottom
);
397 if (IsThemeBackgroundPartiallyTransparent (pdi
.theme
, part
, 0))
398 DrawThemeParentBackground (infoPtr
->Self
, hdc
, NULL
);
399 DrawThemeBackground (pdi
.theme
, hdc
, part
, 0, &pdi
.rect
, NULL
);
400 SelectClipRgn (hdc
, NULL
);
401 CopyRect (&pdi
.rect
, &cntRect
);
404 /* compute some drawing parameters */
405 barSmooth
= (dwStyle
& PBS_SMOOTH
) && !pdi
.theme
;
406 drawProcs
= &((pdi
.theme
? drawProcThemed
: drawProcClassic
)[(barSmooth
? 0 : 4)
407 + ((dwStyle
& PBS_VERTICAL
) ? 2 : 0)]);
408 barSize
= get_bar_size( dwStyle
, &pdi
.rect
);
411 GetWindowRect( infoPtr
->Self
, &pdi
.bgRect
);
412 ScreenToClient( infoPtr
->Self
, (POINT
*)&pdi
.bgRect
);
413 ScreenToClient( infoPtr
->Self
, (POINT
*)&pdi
.bgRect
.right
);
417 pdi
.ledW
= get_led_size( infoPtr
, dwStyle
, &pdi
.rect
);
418 pdi
.ledGap
= get_led_gap( infoPtr
);
420 if (dwStyle
& PBS_MARQUEE
)
422 const int ledW
= !barSmooth
? (pdi
.ledW
+ pdi
.ledGap
) : 1;
423 const int leds
= (barSize
+ ledW
- 1) / ledW
;
424 const int ledMEnd
= infoPtr
->MarqueePos
+ MARQUEE_LEDS
;
428 /* case 1: the marquee bar extends over the end and wraps around to
430 const int gapStart
= max((ledMEnd
- leds
) * ledW
, 0);
431 const int gapEnd
= min(infoPtr
->MarqueePos
* ledW
, barSize
);
433 drawProcs
[0]( &pdi
, 0, gapStart
);
434 drawProcs
[1]( &pdi
, gapStart
, gapEnd
);
435 drawProcs
[0]( &pdi
, gapEnd
, barSize
);
439 /* case 2: the marquee bar is between start and end */
440 const int barStart
= infoPtr
->MarqueePos
* ledW
;
441 const int barEnd
= min (ledMEnd
* ledW
, barSize
);
443 drawProcs
[1]( &pdi
, 0, barStart
);
444 drawProcs
[0]( &pdi
, barStart
, barEnd
);
445 drawProcs
[1]( &pdi
, barEnd
, barSize
);
450 int barEnd
= get_bar_position( infoPtr
, dwStyle
, &pdi
.rect
,
454 const int ledW
= pdi
.ledW
+ pdi
.ledGap
;
455 barEnd
= min (((barEnd
+ ledW
- 1) / ledW
) * ledW
, barSize
);
457 drawProcs
[0]( &pdi
, 0, barEnd
);
458 drawProcs
[1]( &pdi
, barEnd
, barSize
);
461 /* delete bar brush */
462 if (infoPtr
->ColorBar
!= CLR_DEFAULT
) DeleteObject (pdi
.hbrBar
);
463 if (infoPtr
->ColorBk
!= CLR_DEFAULT
) DeleteObject (pdi
.hbrBk
);
468 /***********************************************************************
470 * Draw the progress bar. The background need not be erased.
471 * If dc!=0, it draws on it
473 static LRESULT
PROGRESS_Paint (PROGRESS_INFO
*infoPtr
, HDC hdc
)
476 if (hdc
) return PROGRESS_Draw (infoPtr
, hdc
);
477 hdc
= BeginPaint (infoPtr
->Self
, &ps
);
478 PROGRESS_Draw (infoPtr
, hdc
);
479 EndPaint (infoPtr
->Self
, &ps
);
484 /***********************************************************************
486 * Handle the marquee timer messages
488 static LRESULT
PROGRESS_Timer (PROGRESS_INFO
*infoPtr
, INT idTimer
)
490 if(idTimer
== ID_MARQUEE_TIMER
)
492 LONG style
= GetWindowLongW (infoPtr
->Self
, GWL_STYLE
);
495 HTHEME theme
= GetWindowTheme (infoPtr
->Self
);
496 BOOL barSmooth
= (style
& PBS_SMOOTH
) && !theme
;
498 get_client_rect (infoPtr
->Self
, &rect
);
501 ledWidth
= get_led_size( infoPtr
, style
, &rect
) +
502 get_led_gap( infoPtr
);
506 leds
= (get_bar_size( style
, &rect
) + ledWidth
- 1) /
509 /* increment the marquee progress */
510 if(++infoPtr
->MarqueePos
>= leds
)
512 infoPtr
->MarqueePos
= 0;
515 InvalidateRect(infoPtr
->Self
, &rect
, FALSE
);
516 UpdateWindow(infoPtr
->Self
);
522 /***********************************************************************
524 * Makes sure the current position (CurVal) is within bounds.
526 static void PROGRESS_CoercePos(PROGRESS_INFO
*infoPtr
)
528 if(infoPtr
->CurVal
< infoPtr
->MinVal
)
529 infoPtr
->CurVal
= infoPtr
->MinVal
;
530 if(infoPtr
->CurVal
> infoPtr
->MaxVal
)
531 infoPtr
->CurVal
= infoPtr
->MaxVal
;
535 /***********************************************************************
537 * Set new Font for progress bar
539 static HFONT
PROGRESS_SetFont (PROGRESS_INFO
*infoPtr
, HFONT hFont
, BOOL bRedraw
)
541 HFONT hOldFont
= infoPtr
->Font
;
542 infoPtr
->Font
= hFont
;
543 /* Since infoPtr->Font is not used, there is no need for repaint */
547 static DWORD
PROGRESS_SetRange (PROGRESS_INFO
*infoPtr
, int low
, int high
)
549 DWORD res
= MAKELONG(LOWORD(infoPtr
->MinVal
), LOWORD(infoPtr
->MaxVal
));
551 /* if nothing changes, simply return */
552 if(infoPtr
->MinVal
== low
&& infoPtr
->MaxVal
== high
) return res
;
554 infoPtr
->MinVal
= low
;
555 infoPtr
->MaxVal
= high
;
556 PROGRESS_CoercePos(infoPtr
);
557 InvalidateRect(infoPtr
->Self
, NULL
, TRUE
);
561 /***********************************************************************
564 static LRESULT WINAPI
ProgressWindowProc(HWND hwnd
, UINT message
,
565 WPARAM wParam
, LPARAM lParam
)
567 PROGRESS_INFO
*infoPtr
;
568 static const WCHAR themeClass
[] = {'P','r','o','g','r','e','s','s',0};
571 TRACE("hwnd=%p msg=%04x wparam=%x lParam=%lx\n", hwnd
, message
, wParam
, lParam
);
573 infoPtr
= (PROGRESS_INFO
*)GetWindowLongPtrW(hwnd
, 0);
575 if (!infoPtr
&& message
!= WM_CREATE
)
576 return DefWindowProcW( hwnd
, message
, wParam
, lParam
);
581 DWORD dwExStyle
= GetWindowLongW (hwnd
, GWL_EXSTYLE
);
583 theme
= OpenThemeData (hwnd
, themeClass
);
585 dwExStyle
&= ~(WS_EX_CLIENTEDGE
| WS_EX_WINDOWEDGE
);
586 if (!theme
) dwExStyle
|= WS_EX_STATICEDGE
;
587 SetWindowLongW (hwnd
, GWL_EXSTYLE
, dwExStyle
);
588 /* Force recalculation of a non-client area */
589 SetWindowPos(hwnd
, 0, 0, 0, 0, 0,
590 SWP_FRAMECHANGED
| SWP_NOSIZE
| SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
592 /* allocate memory for info struct */
593 infoPtr
= (PROGRESS_INFO
*)Alloc (sizeof(PROGRESS_INFO
));
594 if (!infoPtr
) return -1;
595 SetWindowLongPtrW (hwnd
, 0, (DWORD_PTR
)infoPtr
);
597 /* initialize the info struct */
598 infoPtr
->Self
= hwnd
;
600 infoPtr
->MaxVal
= 100;
603 infoPtr
->MarqueePos
= 0;
604 infoPtr
->Marquee
= FALSE
;
605 infoPtr
->ColorBar
= CLR_DEFAULT
;
606 infoPtr
->ColorBk
= CLR_DEFAULT
;
609 TRACE("Progress Ctrl creation, hwnd=%p\n", hwnd
);
614 TRACE("Progress Ctrl destruction, hwnd=%p\n", hwnd
);
616 SetWindowLongPtrW(hwnd
, 0, 0);
617 theme
= GetWindowTheme (hwnd
);
618 CloseThemeData (theme
);
625 return (LRESULT
)infoPtr
->Font
;
628 return (LRESULT
)PROGRESS_SetFont(infoPtr
, (HFONT
)wParam
, (BOOL
)lParam
);
631 return PROGRESS_Paint (infoPtr
, (HDC
)wParam
);
634 return PROGRESS_Timer (infoPtr
, (INT
)wParam
);
636 case WM_THEMECHANGED
:
638 DWORD dwExStyle
= GetWindowLongW (hwnd
, GWL_EXSTYLE
);
640 theme
= GetWindowTheme (hwnd
);
641 CloseThemeData (theme
);
642 theme
= OpenThemeData (hwnd
, themeClass
);
644 /* WS_EX_STATICEDGE disappears when the control is themed */
646 dwExStyle
&= ~WS_EX_STATICEDGE
;
648 dwExStyle
|= WS_EX_STATICEDGE
;
649 SetWindowLongW (hwnd
, GWL_EXSTYLE
, dwExStyle
);
651 InvalidateRect (hwnd
, NULL
, FALSE
);
658 oldVal
= infoPtr
->CurVal
;
660 infoPtr
->CurVal
+= (INT
)wParam
;
661 PROGRESS_CoercePos (infoPtr
);
662 TRACE("PBM_DELTAPOS: current pos changed from %d to %d\n", oldVal
, infoPtr
->CurVal
);
663 PROGRESS_Invalidate( infoPtr
, oldVal
, infoPtr
->CurVal
);
664 UpdateWindow( infoPtr
->Self
);
672 oldVal
= infoPtr
->CurVal
;
673 if(oldVal
!= wParam
) {
674 infoPtr
->CurVal
= (INT
)wParam
;
675 PROGRESS_CoercePos(infoPtr
);
676 TRACE("PBM_SETPOS: current pos changed from %d to %d\n", oldVal
, infoPtr
->CurVal
);
677 PROGRESS_Invalidate( infoPtr
, oldVal
, infoPtr
->CurVal
);
678 UpdateWindow( infoPtr
->Self
);
684 return PROGRESS_SetRange (infoPtr
, (int)LOWORD(lParam
), (int)HIWORD(lParam
));
689 oldStep
= infoPtr
->Step
;
690 infoPtr
->Step
= (INT
)wParam
;
697 oldVal
= infoPtr
->CurVal
;
698 infoPtr
->CurVal
+= infoPtr
->Step
;
699 if(infoPtr
->CurVal
> infoPtr
->MaxVal
)
700 infoPtr
->CurVal
= infoPtr
->MinVal
;
701 if(oldVal
!= infoPtr
->CurVal
)
703 TRACE("PBM_STEPIT: current pos changed from %d to %d\n", oldVal
, infoPtr
->CurVal
);
704 PROGRESS_Invalidate( infoPtr
, oldVal
, infoPtr
->CurVal
);
705 UpdateWindow( infoPtr
->Self
);
711 return PROGRESS_SetRange (infoPtr
, (int)wParam
, (int)lParam
);
715 ((PPBRANGE
)lParam
)->iLow
= infoPtr
->MinVal
;
716 ((PPBRANGE
)lParam
)->iHigh
= infoPtr
->MaxVal
;
718 return wParam
? infoPtr
->MinVal
: infoPtr
->MaxVal
;
721 return infoPtr
->CurVal
;
723 case PBM_SETBARCOLOR
:
724 infoPtr
->ColorBar
= (COLORREF
)lParam
;
725 InvalidateRect(hwnd
, NULL
, TRUE
);
729 infoPtr
->ColorBk
= (COLORREF
)lParam
;
730 InvalidateRect(hwnd
, NULL
, TRUE
);
736 infoPtr
->Marquee
= TRUE
;
737 SetTimer(infoPtr
->Self
, ID_MARQUEE_TIMER
, (UINT
)lParam
, NULL
);
741 infoPtr
->Marquee
= FALSE
;
742 KillTimer(infoPtr
->Self
, ID_MARQUEE_TIMER
);
744 return infoPtr
->Marquee
;
747 if ((message
>= WM_USER
) && (message
< WM_APP
))
748 ERR("unknown msg %04x wp=%04x lp=%08lx\n", message
, wParam
, lParam
);
749 return DefWindowProcW( hwnd
, message
, wParam
, lParam
);
754 /***********************************************************************
755 * PROGRESS_Register [Internal]
757 * Registers the progress bar window class.
759 void PROGRESS_Register (void)
763 ZeroMemory (&wndClass
, sizeof(wndClass
));
764 wndClass
.style
= CS_GLOBALCLASS
| CS_VREDRAW
| CS_HREDRAW
;
765 wndClass
.lpfnWndProc
= (WNDPROC
)ProgressWindowProc
;
766 wndClass
.cbClsExtra
= 0;
767 wndClass
.cbWndExtra
= sizeof (PROGRESS_INFO
*);
768 wndClass
.hCursor
= LoadCursorW (0, (LPWSTR
)IDC_ARROW
);
769 wndClass
.lpszClassName
= PROGRESS_CLASSW
;
771 RegisterClassW (&wndClass
);
775 /***********************************************************************
776 * PROGRESS_Unregister [Internal]
778 * Unregisters the progress bar window class.
780 void PROGRESS_Unregister (void)
782 UnregisterClassW (PROGRESS_CLASSW
, NULL
);