From e78b58727c04dd9624e0688e89d909c88255f732 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Thu, 1 Nov 2007 15:34:35 -0700 Subject: [PATCH] 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 *inf 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, } 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 *infoPt { 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 CREATE 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); -- 1.4.1