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

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46485
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
(cherry picked from commit 620a25ef1d)
Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
oldstable
Nikolay Sivov 2019-01-23 08:25:42 +03:00 committed by Michael Stefaniuc
parent c9a2aa88e9
commit e8a705b4c8
2 changed files with 37 additions and 20 deletions

View File

@ -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)
int oldVal = infoPtr->CurVal;
if (infoPtr->MinVal != infoPtr->MaxVal)
{
infoPtr->CurVal = (infoPtr->CurVal - infoPtr->MinVal) % (infoPtr->MaxVal - infoPtr->MinVal) + infoPtr->MinVal;
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 (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 );
}
return oldVal;
}

View File

@ -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);