我使用的是Delphi7。
我知道我可以在TMonthCalendar的OnGetMonthInfo事件中使用BoldDays来传递我希望以粗体显示的日期数组。
我的问题是,如果保存了一个新的日历条目,我就不能手动调用OnGetMonthInfo事件。
使用
MyCalendar.Date:=IncMonth(MyCalendar.Date, -1);
MyCalendar.Date:=IncMonth(MyCalendar.Date, 1);将刷新日历和加粗的月份,但在Vista和Windows7下,这会产生令人讨厌的日历“滚动”效果。
有没有办法在没有“特效”的情况下更新它?
谢谢!
发布于 2010-11-19 20:15:09
您可以通过发送MCM_SETDAYSTATE消息强制刷新当前显示的日历。
除了响应GetMonthInfo事件的代码之外
procedure TForm1.GetMonthBoldInfo(month:cardinal):cardinal;
begin
...
end;
procedure TForm1.MonthCalendar1GetMonthInfo(Sender: TObject;
Month: Cardinal; var MonthBoldInfo: Cardinal);
begin
monthBoldInfo:=GetMonthBoldInfo(month);
end;当日历条目更改时,您需要一些代码来刷新...
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));https://stackoverflow.com/questions/4224225
复制相似问题