Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46485 Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/comctl32/progress.c | 31 ++++++++++++++++--------------- dlls/comctl32/tests/progress.c | 26 +++++++++++++++++++++----- 2 files changed, 37 insertions(+), 20 deletions(-)
diff --git a/dlls/comctl32/progress.c b/dlls/comctl32/progress.c index 28d9fd2fd3..268bdac5da 100644 --- a/dlls/comctl32/progress.c +++ b/dlls/comctl32/progress.c @@ -652,23 +652,24 @@ static LRESULT WINAPI ProgressWindowProc(HWND hwnd, UINT message,
case PBM_STEPIT: { - INT oldVal; - oldVal = infoPtr->CurVal; - infoPtr->CurVal += infoPtr->Step; - if (infoPtr->CurVal > infoPtr->MaxVal) - { - infoPtr->CurVal = (infoPtr->CurVal - infoPtr->MinVal) % (infoPtr->MaxVal - infoPtr->MinVal) + infoPtr->MinVal; - } - if (infoPtr->CurVal < infoPtr->MinVal) + int oldVal = infoPtr->CurVal; + + if (infoPtr->MinVal != infoPtr->MaxVal) { - infoPtr->CurVal = (infoPtr->CurVal - infoPtr->MinVal) % (infoPtr->MaxVal - infoPtr->MinVal) + infoPtr->MaxVal; + infoPtr->CurVal += infoPtr->Step; + 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); + PROGRESS_Invalidate( infoPtr, oldVal, infoPtr->CurVal ); + UpdateWindow( infoPtr->Self ); + } } - if(oldVal != infoPtr->CurVal) - { - TRACE("PBM_STEPIT: current pos changed from %d to %d\n", oldVal, infoPtr->CurVal); - PROGRESS_Invalidate( infoPtr, oldVal, infoPtr->CurVal ); - UpdateWindow( infoPtr->Self ); - } + return oldVal; }
diff --git a/dlls/comctl32/tests/progress.c b/dlls/comctl32/tests/progress.c index 497cb47d3c..91ea6eec2a 100644 --- a/dlls/comctl32/tests/progress.c +++ b/dlls/comctl32/tests/progress.c @@ -254,6 +254,13 @@ static void test_PBM_STEPIT(void) { 3, 15, 5 }, { 3, 15, -5 }, { 3, 15, 50 }, + { -15, 15, 5 }, + { -3, -2, -5 }, + { 0, 0, 1 }, + { 5, 5, 1 }, + { 0, 0, -1 }, + { 5, 5, -1 }, + { 10, 5, 2 }, }; HWND progress; int i, j; @@ -261,6 +268,7 @@ static void test_PBM_STEPIT(void) for (i = 0; i < ARRAY_SIZE(stepit_tests); i++) { struct stepit_test *test = &stepit_tests[i]; + PBRANGE range; LRESULT ret;
progress = create_progress(0); @@ -268,6 +276,9 @@ static void test_PBM_STEPIT(void) ret = SendMessageA(progress, PBM_SETRANGE32, test->min, test->max); ok(ret != 0, "Unexpected return value.\n");
+ SendMessageA(progress, PBM_GETRANGE, 0, (LPARAM)&range); + ok(range.iLow == test->min && range.iHigh == test->max, "Unexpected range.\n"); + SendMessageA(progress, PBM_SETPOS, test->min, 0); SendMessageA(progress, PBM_SETSTEP, test->step, 0);
@@ -277,15 +288,20 @@ static void test_PBM_STEPIT(void) int current;
pos += test->step; - if (pos > test->max) - pos = (pos - test->min) % (test->max - test->min) + test->min; - if (pos < test->min) - pos = (pos - test->min) % (test->max - test->min) + test->max; + if (test->min != test->max) + { + if (pos > test->max) + pos = (pos - test->min) % (test->max - test->min) + test->min; + if (pos < test->min) + pos = (pos - test->min) % (test->max - test->min) + test->max; + } + else + pos = test->min;
SendMessageA(progress, PBM_STEPIT, 0, 0);
current = SendMessageA(progress, PBM_GETPOS, 0, 0); - ok(current == pos, "Unexpected position %d, expected %d.\n", current, pos); + ok(current == pos, "%u: unexpected position %d, expected %d.\n", i, current, pos); }
DestroyWindow(progress);