In the process of migrating one of my Win32 VCL application from Delphi 2006 to delphi XE6 I encountered the following issue :
One of my forms has a TMonthCalendar (plugged on a TPanel for the record) to help the user select a week to view in a graph. By week I mean Monday being the first day and Sunday the last (french locale). To achieve such a week selection pattern I set the multiSelect property to true and put the following code inside the CalendarClick event :
MonthCalendar1.MultiSelect := True;
//Temporarily storing the selected day in a variable
TempoDate := MonthCalendar1.Date;
//searching for the monday right before the selected day (by user)
while dayOfWeek(TempoDate) <> 2 do
TempoDate := IncDay( TempoDate , -1 );
//Setting the monday as the start date of the selection
MonthCalendar1.Date := TempoDate;
//Setting the Sunday as the last day of selection
MonthCalendar1.EndDate := IncDay(tempoDate, 6);
That used to work well on Delphi 2006 ( compiled on a win XP computer ). Now that I have ported the same code to Delphi XE6 ( compiled on a win7 computer ) I have the following problems :
- When clicking the right arrow (>) to switch to the next month it fails most of the time. It actually fails when the monday of the week containing the 1st of the next month is still in the previous month. Ex : switching from Sept '14 to Oct '14 fails because the monday before Oct. 1st is in september (Monday Sept. 29th). So that brings me back to September. On the other hand, switching from August 14 to September 14 works because Sept. 1st is a monday.
- When clicking on the first days of the next month (the few grey one you can click on) the month doesn't switch anymore.
all that used to work before.
I've made some specific isolation tests :
- Creating a minimal app under XE6 with the same behaviour -> still fails (of course)
- Creating the same minimal app under Delphi 2006 -> it all work as expected.
My intuition is that the TMonthCalendar now takes the .Date property to define which month to show, while on D2006 it used to take .EndDate property. Doesn't know if this is a VCL evolution or a microsoft MonthCalendar underlying component behaviour change (since i compiled on XP then SEVEN ).
Thanks for your help
Useful documentation :
http://docwiki.embarcadero.com/Libraries/XE7/en/Vcl.ComCtrls.TMonthCalendar http://msdn.microsoft.com/en-us/library/system.windows.forms.monthcalendar(v=vs.110).aspx