Signed-off-by: Fabian Maurer dark.shadow4@web.de --- dlls/comctl32/progress.c | 10 +++++++-- dlls/comctl32/tests/progress.c | 49 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 2 deletions(-)
diff --git a/dlls/comctl32/progress.c b/dlls/comctl32/progress.c index 80cced4c66..28d9fd2fd3 100644 --- a/dlls/comctl32/progress.c +++ b/dlls/comctl32/progress.c @@ -655,8 +655,14 @@ static LRESULT WINAPI ProgressWindowProc(HWND hwnd, UINT message, INT oldVal; oldVal = infoPtr->CurVal; infoPtr->CurVal += infoPtr->Step; - if(infoPtr->CurVal > infoPtr->MaxVal) - infoPtr->CurVal = infoPtr->MinVal; + if (infoPtr->CurVal > infoPtr->MaxVal) + { + infoPtr->CurVal = (infoPtr->CurVal - infoPtr->MinVal) % (infoPtr->MaxVal - infoPtr->MinVal) + infoPtr->MinVal; + } + if (infoPtr->CurVal < infoPtr->MinVal) + { + infoPtr->CurVal = (infoPtr->CurVal - infoPtr->MinVal) % (infoPtr->MaxVal - infoPtr->MinVal) + infoPtr->MaxVal; + } if(oldVal != infoPtr->CurVal) { TRACE("PBM_STEPIT: current pos changed from %d to %d\n", oldVal, infoPtr->CurVal); diff --git a/dlls/comctl32/tests/progress.c b/dlls/comctl32/tests/progress.c index 9dd4b55202..38907d7a64 100644 --- a/dlls/comctl32/tests/progress.c +++ b/dlls/comctl32/tests/progress.c @@ -237,6 +237,54 @@ static void test_setcolors(void) DestroyWindow(progress); }
+static void test_PBM_STEPIT(void) +{ + HWND progress; + int pos_actual; + int pos_expected; + int i; + + progress = create_progress(0); + SendMessageA(progress, PBM_SETRANGE32, 3, 15); + + /* Test with small steps */ + + SendMessageA(progress, PBM_SETPOS, 3, 0); + SendMessageA(progress, PBM_SETSTEP, 5, 0); + for (i = 1; i < 15; i++) + { + SendMessageA(progress, PBM_STEPIT, 0, 0); + pos_actual = SendMessageA(progress, PBM_GETPOS, 0, 0); + pos_expected = (i * 5) % (15 - 3) + 3; + if (pos_expected == 3) + pos_expected = 15; + ok(pos_actual == pos_expected, "Run %d: Expected %d, got %d\n", i, pos_expected, pos_actual); + } + + /* Test with negative steps */ + + SendMessageA(progress, PBM_SETPOS, 3, 0); + SendMessageA(progress, PBM_SETSTEP, -5, 0); + for (i = 1; i < 15; i++) + { + SendMessageA(progress, PBM_STEPIT, 0, 0); + pos_actual = SendMessageA(progress, PBM_GETPOS, 0, 0); + pos_expected = (i * (-5)) % (15 - 3) + 15; + if (pos_expected == 15) + pos_expected = 3; + ok(pos_actual == pos_expected, "Run %d: Expected %d, got %d\n", i, pos_expected, pos_actual); + } + + /* Test with a step that is multiple times the maximum */ + + SendMessageA(progress, PBM_SETPOS, 3, 0); + SendMessageA(progress, PBM_SETSTEP, 50, 0); + SendMessageA(progress, PBM_STEPIT, 0, 0); + pos_actual = SendMessageA(progress, PBM_GETPOS, 0, 0); + pos_expected = 50 % 15; + ok(pos_actual == pos_expected, "Expected %d, got %d\n", pos_expected, pos_actual); +} + static void init_functions(void) { HMODULE hComCtl32 = LoadLibraryA("comctl32.dll"); @@ -260,6 +308,7 @@ START_TEST(progress)
test_redraw(); test_setcolors(); + test_PBM_STEPIT();
cleanup(); }