【问题标题】:Refreshing BoldDays of TMonthCalendar manually?手动刷新 TMonthCalendar 的 BoldDays?
【发布时间】:2010-11-19 10:47:19
【问题描述】:

我正在使用 Delphi7。

我知道我可以在 TMonthCalendar 的 OnGetMonthInfo 事件中使用 BoldDays 来传递我希望以粗体显示的天数。

我的问题是,如果保存了新的日历条目,我无法手动调用 OnGetMonthInfo 事件。

使用

  MyCalendar.Date:=IncMonth(MyCalendar.Date, -1);
  MyCalendar.Date:=IncMonth(MyCalendar.Date, 1);

会刷新日历和加粗的月份,但在 Vista 和 Windows7 下这会产生令人讨厌的日历“滚动”效果。

有没有办法在没有“特效”的情况下更新它?

谢谢!

【问题讨论】:

    标签: delphi delphi-7 monthcalendar


    【解决方案1】:

    您可以通过发送 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));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-11-20
      • 2023-03-22
      • 2012-11-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多