Kanit Therdsteerasukdi : comctl32: datetime: Reject invalid flags in DTM_SETSYSTEMTIME.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Mar 19 08:17:44 CDT 2007


Module: wine
Branch: master
Commit: 2a79d962787c01311faf6dfed7424057a9b20de0
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=2a79d962787c01311faf6dfed7424057a9b20de0

Author: Kanit Therdsteerasukdi <therdste at ucla.edu>
Date:   Sun Mar 18 12:39:40 2007 -0700

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.

---

 dlls/comctl32/datetime.c       |    4 +++-
 dlls/comctl32/tests/datetime.c |   20 ++++++++++++++++++++
 2 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/dlls/comctl32/datetime.c b/dlls/comctl32/datetime.c
index d092308..4f35b4f 100644
--- a/dlls/comctl32/datetime.c
+++ b/dlls/comctl32/datetime.c
@@ -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;
diff --git a/dlls/comctl32/tests/datetime.c b/dlls/comctl32/tests/datetime.c
index a338e7f..cdeeed7 100644
--- a/dlls/comctl32/tests/datetime.c
+++ b/dlls/comctl32/tests/datetime.c
@@ -112,6 +112,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 },
     { 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);




More information about the wine-cvs mailing list