TMonthCalendar& Delphi样式(Delphi XE2) [英] TMonthCalendar & Delphi Styles (Delphi XE2)

查看:253
本文介绍了TMonthCalendar& Delphi样式(Delphi XE2)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TMontCalendar似乎是Windows的包装程序,因此它不受新的VCL样式的影响,您知道解决方案吗?

TMontCalendar seems to be a Windows wrapper so it can't be affected by the new VCL Styles, do you know a solution for it ?

推荐答案

TMonthCalendar SetWindowTheme 功能以禁用日历中的主题,然后可以设置颜色以使其与vcl样式匹配.

The TMonthCalendar is wrapper for the MONTHCAL_CLASS and as far i know this control doesn't support owner draw, but provides the CalColors property which allow you to set the colors of the elements of the calendar, but this property only works when the themes is not enabled. So first you must call the SetWindowTheme function to disable the themes in the calendar and then you can set the colors to match with the vcl styles.

类似这样的东西

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;

结果将是这个

这篇关于TMonthCalendar& Delphi样式(Delphi XE2)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆