comctl32: datetime: Reject invalid flags in DTM_SETSYSTEMTIME

Kanit Therdsteerasukdi therdste at ucla.edu
Sun Mar 18 14:39:40 CDT 2007


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.
-------------- next part --------------
>From 30bff58e51dbcbafc8c3de65f5c744498200f0d4 Mon Sep 17 00:00:00 2001
From: Kanit Therdsteerasukdi <therdste at ucla.edu>
Date: Fri, 16 Mar 2007 16:30:20 -0700
Subject: [PATCH] comctl32: datetime: Reject invalid flags in DTM_SETSYSTEMTIME

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



More information about the wine-patches mailing list