Commit 620a25ef authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

comctl32/progress: Handle min == max case in PBM_STEPIT.

parent 0e094fa9
...@@ -652,23 +652,24 @@ static LRESULT WINAPI ProgressWindowProc(HWND hwnd, UINT message, ...@@ -652,23 +652,24 @@ static LRESULT WINAPI ProgressWindowProc(HWND hwnd, UINT message,
case PBM_STEPIT: case PBM_STEPIT:
{ {
INT oldVal; int oldVal = infoPtr->CurVal;
oldVal = infoPtr->CurVal;
infoPtr->CurVal += infoPtr->Step; if (infoPtr->MinVal != infoPtr->MaxVal)
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; 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; return oldVal;
} }
......
...@@ -254,6 +254,13 @@ static void test_PBM_STEPIT(void) ...@@ -254,6 +254,13 @@ static void test_PBM_STEPIT(void)
{ 3, 15, 5 }, { 3, 15, 5 },
{ 3, 15, -5 }, { 3, 15, -5 },
{ 3, 15, 50 }, { 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; HWND progress;
int i, j; int i, j;
...@@ -261,6 +268,7 @@ static void test_PBM_STEPIT(void) ...@@ -261,6 +268,7 @@ static void test_PBM_STEPIT(void)
for (i = 0; i < ARRAY_SIZE(stepit_tests); i++) for (i = 0; i < ARRAY_SIZE(stepit_tests); i++)
{ {
struct stepit_test *test = &stepit_tests[i]; struct stepit_test *test = &stepit_tests[i];
PBRANGE range;
LRESULT ret; LRESULT ret;
progress = create_progress(0); progress = create_progress(0);
...@@ -268,6 +276,9 @@ static void test_PBM_STEPIT(void) ...@@ -268,6 +276,9 @@ static void test_PBM_STEPIT(void)
ret = SendMessageA(progress, PBM_SETRANGE32, test->min, test->max); ret = SendMessageA(progress, PBM_SETRANGE32, test->min, test->max);
ok(ret != 0, "Unexpected return value.\n"); 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_SETPOS, test->min, 0);
SendMessageA(progress, PBM_SETSTEP, test->step, 0); SendMessageA(progress, PBM_SETSTEP, test->step, 0);
...@@ -277,15 +288,20 @@ static void test_PBM_STEPIT(void) ...@@ -277,15 +288,20 @@ static void test_PBM_STEPIT(void)
int current; int current;
pos += test->step; pos += test->step;
if (pos > test->max) if (test->min != test->max)
pos = (pos - test->min) % (test->max - test->min) + test->min; {
if (pos < test->min) if (pos > test->max)
pos = (pos - test->min) % (test->max - test->min) + 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); SendMessageA(progress, PBM_STEPIT, 0, 0);
current = SendMessageA(progress, PBM_GETPOS, 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); DestroyWindow(progress);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment