Reputation: 2520
I'm using Delphi7.
I know that I can use BoldDays in OnGetMonthInfo event of a TMonthCalendar to pass an array of days that I'd like to appear in bold.
My problem is that if a new calendar entry is saved, I can't call the OnGetMonthInfo event manually.
Using
MyCalendar.Date:=IncMonth(MyCalendar.Date, -1);
MyCalendar.Date:=IncMonth(MyCalendar.Date, 1);
will refresh the calendar and the bolded months, but under Vista and Windows7 this produces an annoying "rolling" effect of the calendar.
Is there a way to update it without the "special effect"?
Thanks!
Upvotes: 1
Views: 2903
Reputation: 29339
You may force the refresh of the currently displayed calendars by sending the MCM_SETDAYSTATE message.
in addition to the code to respond to the GetMonthInfo event
procedure TForm1.GetMonthBoldInfo(month:cardinal):cardinal;
begin
...
end;
procedure TForm1.MonthCalendar1GetMonthInfo(Sender: TObject;
Month: Cardinal; var MonthBoldInfo: Cardinal);
begin
monthBoldInfo:=GetMonthBoldInfo(month);
end;
you need some code to refresh when a calendar entry changes...
var DayStates: array[0..2] of integer;
....
DayStates[0]:=GetMonthBoldInfo(month-1);
DayStates[1]:=GetMonthBoldInfo(month);
DayStates[2]:=GetMonthBoldInfo(month+1);
SendMessage(MonthCalendar1.Handle, MCM_SETDAYSTATE, 3, longint(@DayStates));
Upvotes: 2