comctl32/monthcal: Fix parameter validation in MCM_SETMAXSELCOUNT handler.

This commit is contained in:
Nikolay Sivov 2009-10-01 23:02:56 +04:00 committed by Alexandre Julliard
parent 3df0823085
commit 5d530fee54
2 changed files with 17 additions and 5 deletions

View File

@ -1087,9 +1087,10 @@ MONTHCAL_SetMaxSelCount(MONTHCAL_INFO *infoPtr, INT max)
{
TRACE("%d\n", max);
if(infoPtr->dwStyle & MCS_MULTISELECT) {
if(!(infoPtr->dwStyle & MCS_MULTISELECT)) return FALSE;
if(max <= 0) return FALSE;
infoPtr->maxSelCount = max;
}
return TRUE;
}

View File

@ -1316,6 +1316,10 @@ static void test_monthcal_maxselday(void)
/* if no style specified default to 1 */
res = SendMessage(hwnd, MCM_GETMAXSELCOUNT, 0, 0);
expect(1, res);
res = SendMessage(hwnd, MCM_SETMAXSELCOUNT, 5, 0);
expect(0, res);
res = SendMessage(hwnd, MCM_GETMAXSELCOUNT, 0, 0);
expect(1, res);
/* try to set style */
style = GetWindowLong(hwnd, GWL_STYLE);
@ -1351,13 +1355,20 @@ static void test_monthcal_maxselday(void)
res = SendMessage(hwnd, MCM_GETMAXSELCOUNT, 0, 0);
expect(15, res);
/* test invalid value */
res = SendMessage(hwnd, MCM_SETMAXSELCOUNT, -1, 0);
todo_wine {expect(0, res);}
expect(0, res);
res = SendMessage(hwnd, MCM_GETMAXSELCOUNT, 0, 0);
todo_wine {expect(15, res);}
expect(15, res);
ok_sequence(sequences, MONTHCAL_SEQ_INDEX, monthcal_max_sel_day_seq, "monthcal MaxSelDay", FALSE);
/* zero value is invalid too */
res = SendMessage(hwnd, MCM_SETMAXSELCOUNT, 0, 0);
expect(0, res);
res = SendMessage(hwnd, MCM_GETMAXSELCOUNT, 0, 0);
expect(15, res);
DestroyWindow(hwnd);
}