【问题标题】:TMonthCalendar & Delphi Styles (Delphi XE2)TMonthCalendar & Delphi Styles (Delphi XE2)
【发布时间】:2012-04-10 12:52:50
【问题描述】:

TMontCalendar 似乎是一个 Windows 包装器,因此它不会受到新的 VCL 样式的影响,你知道它的解决方案吗?

【问题讨论】:

标签: delphi delphi-xe2 vcl-styles


【解决方案1】:

TMonthCalendarMONTHCAL_CLASS 的包装,据我所知,此控件不支持所有者绘制,但提供了CalColors 属性,该属性允许您设置日历元素的颜色,但是此属性仅在未启用主题时有效。所以首先你必须调用SetWindowTheme函数来禁用日历中的主题,然后你可以设置颜色以匹配vcl样式。

类似的东西

uses
  Vcl.Styles,
  Vcl.Themes,
  uxTheme;

Procedure SetVclStylesColorsCalendar( MonthCalendar: TMonthCalendar);
Var
  LTextColor, LBackColor : TColor;
begin
   uxTheme.SetWindowTheme(MonthCalendar.Handle, '', '');//disable themes in the calendar
   MonthCalendar.AutoSize:=True;//remove border

   //get the vcl styles colors
   LTextColor:=StyleServices.GetSystemColor(clWindowText);
   LBackColor:=StyleServices.GetSystemColor(clWindow);

   //set the colors of the calendar
   MonthCalendar.CalColors.BackColor:=LBackColor;
   MonthCalendar.CalColors.MonthBackColor:=LBackColor;
   MonthCalendar.CalColors.TextColor:=LTextColor;
   MonthCalendar.CalColors.TitleBackColor:=LBackColor;
   MonthCalendar.CalColors.TitleTextColor:=LTextColor;
   MonthCalendar.CalColors.TrailingTextColor:=LTextColor;
end;

结果会是这样的

【讨论】:

  • 好吧,我或多或少是一样的。但你的真的更清晰、更聪明!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-03-24
  • 2011-12-19
  • 2023-03-27
  • 2014-03-06
  • 2012-09-22
  • 2011-11-26
  • 2012-11-10
相关资源
最近更新 更多