Lei Zhang : comctl32: Datetime should close its monthcal when the monthcal loses focus.

Alexandre Julliard julliard at winehq.org
Fri Nov 2 08:10:27 CDT 2007


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

Author: Lei Zhang <thestig at google.com>
Date:   Thu Nov  1 15:34:35 2007 -0700

comctl32: Datetime should close its monthcal when the monthcal loses focus.

---

 dlls/comctl32/datetime.c |   24 +++++++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/dlls/comctl32/datetime.c b/dlls/comctl32/datetime.c
index 40c2ca5..8689dd5 100644
--- a/dlls/comctl32/datetime.c
+++ b/dlls/comctl32/datetime.c
@@ -72,6 +72,7 @@ typedef struct
     RECT checkbox;  /* checkbox allowing the control to be enabled/disabled */
     RECT calbutton; /* button that toggles the dropdown of the monthcal control */
     BOOL bCalDepressed; /* TRUE = cal button is depressed */
+    int  bDropdownEnabled;
     int  select;
     HFONT hFont;
     int nrFieldsAllocated;
@@ -739,7 +740,10 @@ DATETIME_LButtonDown (DATETIME_INFO *infoPtr, WORD wKey, INT x, INT y)
             TRACE("update calendar %04d/%02d/%02d\n", 
             lprgSysTimeArray->wYear, lprgSysTimeArray->wMonth, lprgSysTimeArray->wDay);
             SendMessageW(infoPtr->hMonthCal, MCM_SETCURSEL, 0, (LPARAM)(&infoPtr->date));
-            ShowWindow(infoPtr->hMonthCal, SW_SHOW);
+
+            if (infoPtr->bDropdownEnabled)
+                ShowWindow(infoPtr->hMonthCal, SW_SHOW);
+            infoPtr->bDropdownEnabled = TRUE;
         }
 
         TRACE ("dt:%p mc:%p mc parent:%p, desktop:%p\n",
@@ -776,6 +780,10 @@ DATETIME_Paint (DATETIME_INFO *infoPtr, HDC hdc)
     } else {
         DATETIME_Refresh (infoPtr, hdc);
     }
+
+    /* Not a click on the dropdown box, enabled it */
+    infoPtr->bDropdownEnabled = TRUE;
+
     return 0;
 }
 
@@ -1063,6 +1071,19 @@ DATETIME_SetFocus (DATETIME_INFO *infoPtr, HWND lostFocus)
 {
     TRACE("got focus from %p\n", lostFocus);
 
+    /* if monthcal is open and it loses focus, close monthcal */
+    if (infoPtr->hMonthCal && (lostFocus == infoPtr->hMonthCal) && \
+        IsWindowVisible(infoPtr->hMonthCal))
+    {
+        ShowWindow(infoPtr->hMonthCal, SW_HIDE);
+        DATETIME_SendSimpleNotify(infoPtr, DTN_CLOSEUP);
+        /* note: this get triggered even if monthcal loses focus to a dropdown
+         * box click, which occurs without an intermediate WM_PAINT call
+         */
+        infoPtr->bDropdownEnabled = FALSE;
+        return 0;
+    }
+
     if (infoPtr->haveFocus == 0) {
 	DATETIME_SendSimpleNotify (infoPtr, NM_SETFOCUS);
 	infoPtr->haveFocus = DTHT_GOTFOCUS;
@@ -1207,6 +1228,7 @@ DATETIME_Create (HWND hwnd, const CREATESTRUCTW *lpcs)
     infoPtr->buflen = (int *) Alloc (infoPtr->nrFieldsAllocated * sizeof(int));
     infoPtr->hwndNotify = lpcs->hwndParent;
     infoPtr->select = -1; /* initially, nothing is selected */
+    infoPtr->bDropdownEnabled = TRUE;
 
     DATETIME_StyleChanged(infoPtr, GWL_STYLE, &ss);
     DATETIME_SetFormatW (infoPtr, 0);




More information about the wine-cvs mailing list