diff --git a/dlls/comctl32/monthcal.c b/dlls/comctl32/monthcal.c index 384efe78432..ed059ff2981 100644 --- a/dlls/comctl32/monthcal.c +++ b/dlls/comctl32/monthcal.c @@ -1087,9 +1087,10 @@ MONTHCAL_SetMaxSelCount(MONTHCAL_INFO *infoPtr, INT max) { TRACE("%d\n", max); - if(infoPtr->dwStyle & MCS_MULTISELECT) { - infoPtr->maxSelCount = max; - } + if(!(infoPtr->dwStyle & MCS_MULTISELECT)) return FALSE; + if(max <= 0) return FALSE; + + infoPtr->maxSelCount = max; return TRUE; } diff --git a/dlls/comctl32/tests/monthcal.c b/dlls/comctl32/tests/monthcal.c index cd9d15eb863..e0479cd075a 100644 --- a/dlls/comctl32/tests/monthcal.c +++ b/dlls/comctl32/tests/monthcal.c @@ -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); }