经过一段时间的挖掘,这是对我发现的内容的快速解释
Source code here
在文件夹中
\Embarcadero\Studio\17.0\source\fmx
有一个 FMX.Calendar.Style.pas 文件
我已将该文件复制到与我的项目相同的位置并将其重命名为 My.FMX.Calendar.Style.pas
我也将 TStyledCalendar 重命名为 TMyStyledCalendar,然后将初始化和终结从
initialization
TPresentationProxyFactory.Current.Register(TCalendar, TControlType.Styled, TStyledPresentationProxy<TMyStyledCalendar>);
finalization
TPresentationProxyFactory.Current.Unregister(TCalendar, TControlType.Styled, TStyledPresentationProxy<TMyStyledCalendar>);
end.
initialization
TPresentationProxyFactory.Current.Unregister(TCalendar, TControlType.Styled, TStyledPresentationProxy<TStyledCalendar>);
TPresentationProxyFactory.Current.Register(TCalendar, TControlType.Styled, TStyledPresentationProxy<TMyStyledCalendar>);
finalization
TPresentationProxyFactory.Current.Unregister(TCalendar, TControlType.Styled, TStyledPresentationProxy<TMyStyledCalendar>);
还在使用部分添加了 FMX.Calendar.Style
在程序 FillDays 中;创建了一个新程序
procedure ChangeStyle(aDay : TDateTime;Item: TDayItem);
var wDay : Word;
begin
wDay := DayOfWeek(aDay-1);
if (wDay = DaySaturday) or (wday = DaySunday) then begin
item.Enabled := false;
if (Item.StyleLookup <> 'MyListBoxItemstyle') then
Item.StyleLookup := 'MyListBoxItemstyle';
end else begin
if (Item.StyleLookup <> '') then
Item.StyleLookup := '';
end;
end;
并添加了 ChangeStyle(Item.Date, Item);到下一个 FillDaysOfPreviousMonth; FillDaysOfCurrentMonth; FillDaysOfNextMonth;
添加了一个样式来匹配 MyListBoxItemstyle
在玩过这些样式之后,它看起来像这样