Question

Drop a TMonthCalendar control onto a form. Set it to show one month. Use US English locale (Sunday as first day of week). View January 2013. Your calendar actually is showing December 30th, 2012 to February 9th, 2013 because it shows 42 days total. Set your MaxSelCount to 42 and set MultiSelect to true so you can select and number of these days.

Issue 1 - Click on December 31st, and hold the mouse down. Drag to January 1st and let go. You have two days selected. Works as expected. Clear this selection by selecting another date in January. Now select the same two days again, but this time select January 1st FIRST, and drag left in order to get December 31st highlighted. Notice how the calendar scrolls left into December? How can I stop the calendar from scrolling???

Issue 2 - In both scenarios above you had the same two dates selected, but the displayed month of the calendar was completely different. How can I tell what month is actually being displayed by the calendar?

Issue 3 - Select from January 24th to February 1st. The calendar now scrolls to February, and then cuts off the 24th, 25th, and 26th from view. Seems completely broken.

I've also tried the Jedi controls which are wrappers.

Was it helpful?

Solution

The easy one is the second one. You can simply use the MCM_GETMONTHRANGE message – or, more simply, the MonthCal_GetMonthRange 'macro' – to obtain this information.

For example (uses CommCtrl),

procedure TForm1.FormClick(Sender: TObject);
var
  st: array[0..1] of TSystemTime;
begin
  MonthCal_GetMonthRange(MonthCalendar1.Handle, GMR_VISIBLE, @st);
  Caption := IntToStr(st[0].wMonth);
end;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top