TMontCalendar 似乎是一个 Windows 包装器,因此它不会受到新的 VCL 样式的影响,您知道解决方案吗?
The TMonthCalendar http://docwiki.embarcadero.com/Libraries/en/Vcl.ComCtrls.TMonthCalendar是包装MONTHCAL_CLASS http://msdn.microsoft.com/en-us/library/windows/desktop/bb775491%28v=vs.85%29.aspx据我所知,这个控件不支持所有者绘制,但提供CalColors http://docwiki.embarcadero.com/Libraries/XE2/en/Vcl.ComCtrls.TMonthCalendar.CalColors属性允许您设置日历元素的颜色,但此属性仅在未启用主题时有效。所以首先你必须调用设置窗口主题 http://msdn.microsoft.com/en-us/library/windows/desktop/bb759827%28v=vs.85%29.aspx函数禁用日历中的主题,然后您可以设置颜色以与 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;
结果将是这样的
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)