comctl32: datetime: Reject invalid flags in DTM_SETSYSTEMTIME.

Reject invalid flags in DTM_SETSYSTEMTIME i.e. when the flag is neither
GDT_VALID nor GDT_NONE when the style is set to DTS_SHOWNONE.  Corresponding
setters and message sequence tests were also added.
This commit is contained in:
Kanit Therdsteerasukdi 2007-03-18 12:39:40 -07:00 committed by Alexandre Julliard
parent c9ca25aa1d
commit 2a79d96278
2 changed files with 23 additions and 1 deletions

View File

@ -176,10 +176,12 @@ DATETIME_SetSystemTime (DATETIME_INFO *infoPtr, DWORD flag, SYSTEMTIME *lprgSysT
MONTHCAL_CopyTime (lprgSysTimeArray, &infoPtr->date);
SendMessageW (infoPtr->hMonthCal, MCM_SETCURSEL, 0, (LPARAM)(&infoPtr->date));
SendMessageW (infoPtr->hwndCheckbut, BM_SETCHECK, BST_CHECKED, 0);
} else if (flag == GDT_NONE) {
} else if ((infoPtr->dwStyle & DTS_SHOWNONE) && (flag == GDT_NONE)) {
infoPtr->dateValid = FALSE;
SendMessageW (infoPtr->hwndCheckbut, BM_SETCHECK, BST_UNCHECKED, 0);
}
else
return 0;
InvalidateRect(infoPtr->hwndSelf, NULL, TRUE);
return TRUE;

View File

@ -111,6 +111,9 @@ static const struct message test_dtm_set_range_swap_min_max_seq[] = {
};
static const struct message test_dtm_set_and_get_system_time_seq[] = {
{ DTM_SETSYSTEMTIME, sent|wparam, 0x00000001 },
{ WM_DESTROY, sent|wparam|lparam, 0x00000000, 0x00000000 },
{ WM_NCDESTROY, sent|wparam|lparam, 0x00000000, 0x00000000 },
{ DTM_SETSYSTEMTIME, sent|wparam, 0x00000001 },
{ DTM_GETSYSTEMTIME, sent|wparam, 0x00000000 },
{ DTM_SETSYSTEMTIME, sent|wparam, 0x00000000 },
@ -477,6 +480,23 @@ static void test_dtm_set_and_get_system_time(HWND hWndDateTime)
LRESULT r;
SYSTEMTIME st;
SYSTEMTIME getSt;
HWND hWndDateTime_test_gdt_none;
hWndDateTime_test_gdt_none = create_datetime_control(0, 0);
ok(hWndDateTime_test_gdt_none!=NULL, "Expected non NULL, got %p\n", hWndDateTime_test_gdt_none);
if(hWndDateTime_test_gdt_none) {
r = SendMessage(hWndDateTime_test_gdt_none, DTM_SETSYSTEMTIME, GDT_NONE, (LPARAM)&st);
expect(0, r);
}
else {
skip("hWndDateTime_test_gdt_none is NULL\n");
flush_sequences(sequences, NUM_MSG_SEQUENCES);
return;
}
DestroyWindow(hWndDateTime_test_gdt_none);
r = SendMessage(hWndDateTime, DTM_SETSYSTEMTIME, GDT_NONE, (LPARAM)&st);
expect(1, r);