From: Jacob Czekalla jczekalla@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=56352 --- dlls/comctl32/progress.c | 28 ++++++++++++++++++++++------ dlls/comctl32/tests/progress.c | 6 +++--- dlls/comctl32/tests/taskdialog.c | 4 ++-- 3 files changed, 27 insertions(+), 11 deletions(-)
diff --git a/dlls/comctl32/progress.c b/dlls/comctl32/progress.c index 6d556f10094..fcecd7bb293 100644 --- a/dlls/comctl32/progress.c +++ b/dlls/comctl32/progress.c @@ -53,6 +53,7 @@ typedef struct COLORREF ColorBar; /* Bar color */ COLORREF ColorBk; /* Background color */ HFONT Font; /* Handle to font (not unused) */ + UINT State; /* State of progress bar */ } PROGRESS_INFO;
/* Control configuration constants */ @@ -147,6 +148,7 @@ typedef struct tagProgressDrawInfo int ledW, ledGap; HTHEME theme; RECT bgRect; + UINT state; } ProgressDrawInfo;
typedef void (*ProgressDrawProc)(const ProgressDrawInfo* di, int start, int end); @@ -243,7 +245,7 @@ static void draw_theme_bar_H (const ProgressDrawInfo* di, int start, int end) r.top = di->rect.top; r.bottom = di->rect.bottom; r.right = di->rect.left + end; - DrawThemeBackground (di->theme, di->hdc, PP_CHUNK, 0, &r, NULL); + DrawThemeBackground (di->theme, di->hdc, PP_FILL, di->state, &r, NULL); }
/* draw themed vertical bar from 'start' to 'end' */ @@ -254,7 +256,7 @@ static void draw_theme_bar_V (const ProgressDrawInfo* di, int start, int end) r.right = di->rect.right; r.bottom = di->rect.bottom - start; r.top = di->rect.bottom - end; - DrawThemeBackground (di->theme, di->hdc, PP_CHUNKVERT, 0, &r, NULL); + DrawThemeBackground (di->theme, di->hdc, PP_FILLVERT, di->state, &r, NULL); }
/* draw themed horizontal background from 'start' to 'end' */ @@ -310,6 +312,7 @@ static LRESULT PROGRESS_Draw (PROGRESS_INFO *infoPtr, HDC hdc) TRACE("(infoPtr=%p, hdc=%p)\n", infoPtr, hdc);
pdi.hdc = hdc; + pdi.state = infoPtr->State; pdi.theme = GetWindowTheme (infoPtr->Self);
/* get the required bar brush */ @@ -522,6 +525,20 @@ static UINT PROGRESS_SetPos (PROGRESS_INFO *infoPtr, INT pos) } }
+static UINT PROGRESS_SetState (HWND hwnd, PROGRESS_INFO *infoPtr, UINT state) +{ + UINT prev_state = infoPtr->State; + + if (state == PBST_NORMAL || state == PBST_PAUSED || state == PBST_ERROR) + infoPtr->State = state; + else + return 0; + + if (state != prev_state) + InvalidateRect(hwnd, NULL, TRUE); + return prev_state; +} + /*********************************************************************** * ProgressWindowProc */ @@ -569,6 +586,7 @@ static LRESULT WINAPI ProgressWindowProc(HWND hwnd, UINT message, infoPtr->ColorBar = CLR_DEFAULT; infoPtr->ColorBk = CLR_DEFAULT; infoPtr->Font = 0; + infoPtr->State = PBST_NORMAL;
TRACE("Progress Ctrl creation, hwnd=%p\n", hwnd); return 0; @@ -711,12 +729,10 @@ static LRESULT WINAPI ProgressWindowProc(HWND hwnd, UINT message, return infoPtr->ColorBk;
case PBM_SETSTATE: - if(wParam != PBST_NORMAL) - FIXME("state %Ix not yet handled\n", wParam); - return PBST_NORMAL; + return PROGRESS_SetState(hwnd, infoPtr, wParam);
case PBM_GETSTATE: - return PBST_NORMAL; + return infoPtr->State;
case PBM_SETMARQUEE: if(wParam != 0) diff --git a/dlls/comctl32/tests/progress.c b/dlls/comctl32/tests/progress.c index 5660d915f46..092137985fb 100644 --- a/dlls/comctl32/tests/progress.c +++ b/dlls/comctl32/tests/progress.c @@ -392,10 +392,10 @@ void test_bar_states(void) { state = SendMessageA(progress_bar, PBM_SETSTATE, tests[i].state, 0); flush_events(); - ok_sequence(sequences, CHILD_SEQ_INDEX, tests[i].expected_seq, "PBM_SETSTATE", TRUE); - todo_wine ok(state == (tests[i].error ? 0 : tests[i].previous_state), "Expected %ld, but got %d.\n", tests[i].previous_state, state); + ok_sequence(sequences, CHILD_SEQ_INDEX, tests[i].expected_seq, "PBM_SETSTATE", FALSE); + ok(state == (tests[i].error ? 0 : tests[i].previous_state), "Expected %ld, but got %d.\n", tests[i].previous_state, state); state = SendMessageA(progress_bar, PBM_GETSTATE, 0, 0); - todo_wine ok(state == (tests[i].error ? tests[i].previous_state : tests[i].state), "Expected %ld, but got %d.\n", tests[i].state, state); + ok(state == (tests[i].error ? tests[i].previous_state : tests[i].state), "Expected %ld, but got %d.\n", tests[i].state, state); }
DestroyWindow(progress_bar); diff --git a/dlls/comctl32/tests/taskdialog.c b/dlls/comctl32/tests/taskdialog.c index ef60a5953bd..44991256750 100644 --- a/dlls/comctl32/tests/taskdialog.c +++ b/dlls/comctl32/tests/taskdialog.c @@ -722,9 +722,9 @@ static HRESULT CALLBACK taskdialog_callback_proc_progress_bar(HWND hwnd, UINT no ok(ret == PBST_NORMAL, "Expect state: %d got state: %lx\n", PBST_NORMAL, ret); ret = SendMessageW(hwnd, TDM_SET_PROGRESS_BAR_STATE, PBST_ERROR, 0); /* Progress bar has fixme on handling PBM_SETSTATE message */ - todo_wine ok(ret == PBST_PAUSED, "Expect state: %d got state: %lx\n", PBST_PAUSED, ret); + ok(ret == PBST_PAUSED, "Expect state: %d got state: %lx\n", PBST_PAUSED, ret); ret = SendMessageW(hwnd, TDM_SET_PROGRESS_BAR_STATE, PBST_NORMAL, 0); - todo_wine ok(ret == PBST_ERROR, "Expect state: %d got state: %lx\n", PBST_ERROR, ret); + ok(ret == PBST_ERROR, "Expect state: %d got state: %lx\n", PBST_ERROR, ret);
/* TDM_SET_PROGRESS_BAR_RANGE */ ret = SendMessageW(hwnd, TDM_SET_PROGRESS_BAR_RANGE, 0, MAKELPARAM(0, 200));