>From 47a3d4723b3ef28cd3cd8c74880adf2e956f3aeb Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <nsivov@codeweavers.com>
Date: Fri, 23 Sep 2011 14:53:47 +0400
Subject: [PATCH 5/5] Fix jump to today date

---
 dlls/comctl32/monthcal.c |   36 +++++++++++++++++++++++++++---------
 1 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/dlls/comctl32/monthcal.c b/dlls/comctl32/monthcal.c
index d230f34..e73b40a 100644
--- a/dlls/comctl32/monthcal.c
+++ b/dlls/comctl32/monthcal.c
@@ -1491,7 +1491,11 @@ MONTHCAL_SetCurSel(MONTHCAL_INFO *infoPtr, SYSTEMTIME *curSel)
   /* exit earlier if selection equals current */
   if (MONTHCAL_IsDateEqual(&infoPtr->minSel, curSel)) return TRUE;
 
-  if(!MONTHCAL_IsDateInValidRange(infoPtr, curSel, FALSE)) return FALSE;
+  selection = *curSel;
+  selection.wHour = selection.wMinute = selection.wSecond = selection.wMilliseconds = 0;
+  MONTHCAL_CalculateDayOfWeek(&selection, TRUE);
+
+  if(!MONTHCAL_IsDateInValidRange(infoPtr, &selection, FALSE)) return FALSE;
 
   /* scroll calendars only if we have to */
   diff = MONTHCAL_MonthDiff(&infoPtr->calendars[MONTHCAL_GetCalCount(infoPtr)-1].month, curSel);
@@ -1509,6 +1513,7 @@ MONTHCAL_SetCurSel(MONTHCAL_INFO *infoPtr, SYSTEMTIME *curSel)
       MONTHCAL_GetMonth(&infoPtr->calendars[i].month, diff);
   }
 
+  /* we need to store time part as it is */
   selection = *curSel;
   MONTHCAL_CalculateDayOfWeek(&selection, TRUE);
   infoPtr->minSel = infoPtr->maxSel = selection;
@@ -1977,10 +1982,18 @@ MONTHCAL_RButtonUp(MONTHCAL_INFO *infoPtr, LPARAM lParam)
   if( TrackPopupMenu(hMenu, TPM_RIGHTBUTTON | TPM_NONOTIFY | TPM_RETURNCMD,
 		     menupoint.x, menupoint.y, 0, infoPtr->hwndSelf, NULL))
   {
-      infoPtr->calendars[0].month = infoPtr->todaysDate;
-      infoPtr->minSel = infoPtr->todaysDate;
-      infoPtr->maxSel = infoPtr->todaysDate;
-      InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
+      if (infoPtr->dwStyle & MCS_MULTISELECT)
+      {
+          SYSTEMTIME range[2];
+
+          range[0] = range[1] = infoPtr->todaysDate;
+          MONTHCAL_SetSelRange(infoPtr, range);
+      }
+      else
+          MONTHCAL_SetCurSel(infoPtr, &infoPtr->todaysDate);
+
+      MONTHCAL_NotifySelectionChange(infoPtr);
+      MONTHCAL_NotifySelect(infoPtr);
   }
 
   return 0;
@@ -2153,10 +2166,15 @@ MONTHCAL_LButtonDown(MONTHCAL_INFO *infoPtr, LPARAM lParam)
   }
   case MCHT_TODAYLINK:
   {
-    infoPtr->calendars[0].month = infoPtr->todaysDate;
-    infoPtr->minSel = infoPtr->todaysDate;
-    infoPtr->maxSel = infoPtr->todaysDate;
-    InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
+    if (infoPtr->dwStyle & MCS_MULTISELECT)
+    {
+        SYSTEMTIME range[2];
+
+        range[0] = range[1] = infoPtr->todaysDate;
+        MONTHCAL_SetSelRange(infoPtr, range);
+    }
+    else
+        MONTHCAL_SetCurSel(infoPtr, &infoPtr->todaysDate);
 
     MONTHCAL_NotifySelectionChange(infoPtr);
     MONTHCAL_NotifySelect(infoPtr);
-- 
1.5.6.5


