Nikolay Sivov : comctl32/monthcal: Properly compute maximum date for control.

Alexandre Julliard julliard at winehq.org
Thu Sep 15 12:34:53 CDT 2011


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

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Wed Sep 14 22:59:13 2011 +0400

comctl32/monthcal: Properly compute maximum date for control.

---

 dlls/comctl32/monthcal.c |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/dlls/comctl32/monthcal.c b/dlls/comctl32/monthcal.c
index 07a8783..5a6f326 100644
--- a/dlls/comctl32/monthcal.c
+++ b/dlls/comctl32/monthcal.c
@@ -521,15 +521,27 @@ static void MONTHCAL_GetMinDate(const MONTHCAL_INFO *infoPtr, SYSTEMTIME *date)
 static void MONTHCAL_GetMaxDate(const MONTHCAL_INFO *infoPtr, SYSTEMTIME *date)
 {
   /* the latest date is in latest calendar */
-  SYSTEMTIME st, lt_month = infoPtr->calendars[MONTHCAL_GetCalCount(infoPtr)-1].month;
+  SYSTEMTIME st, *lt_month = &infoPtr->calendars[MONTHCAL_GetCalCount(infoPtr)-1].month;
+  INT first_day;
+
+  *date = *lt_month;
+  st = *lt_month;
+
+  /* day of week of first day of current month */
+  st.wDay = 1;
+  first_day = MONTHCAL_CalculateDayOfWeek(&st, FALSE);
 
-  *date = lt_month;
   MONTHCAL_GetNextMonth(date);
+  MONTHCAL_GetPrevMonth(&st);
+
+  /* last calendar starts with some date from previous month that not displayed */
+  st.wDay = MONTHCAL_MonthLength(st.wMonth, st.wYear) +
+             (infoPtr->firstDay - first_day) % 7 + 1;
+  if (st.wDay > MONTHCAL_MonthLength(st.wMonth, st.wYear)) st.wDay -= 7;
 
-  MONTHCAL_GetMinDate(infoPtr, &st);
   /* Use month length to get max day. 42 means max day count in calendar area */
   date->wDay = 42 - (MONTHCAL_MonthLength(st.wMonth, st.wYear) - st.wDay + 1) -
-                     MONTHCAL_MonthLength(lt_month.wMonth, lt_month.wYear);
+                     MONTHCAL_MonthLength(lt_month->wMonth, lt_month->wYear);
 
   /* fix day of week */
   MONTHCAL_CalculateDayOfWeek(date, TRUE);




More information about the wine-cvs mailing list