Delphi 10.4 将默认 VirtualTree 的默认属性存储在 .dfm 文件中

Delphi 10.4 stores default VirtualTree's default properties in .dfm file

更新到 Delphi 10.4 Sydney 后,我的 TVirtualStringTree 实例将它们的 Colors.XYZ 属性存储在 dfm 文件中,尽管我将它们保留为默认值:

VirtualTrees.pas中,这些颜色值有一个默认值,这通常意味着这些颜色值不应写入 dfm 文件:

  published
    property BorderColor: TColor index cBorderColor read GetColor write SetColor default clBtnFace;
    property DisabledColor: TColor index cDisabledColor read GetColor write SetColor default clBtnShadow;
    property DropMarkColor: TColor index cDropMarkColor read GetColor write SetColor default clHighlight;
    ...

如何去除 dfm 文件中的这些默认颜色?

这是因为 StyleServices.IsSystemStyle 在以前的 Delphi 设计器版本中 return 为真,现在在 10.4 中 return 为假。

这将很快在 Virtual TreeView 中得到修复:https://github.com/JAM-Software/Virtual-TreeView/issues/975

根本原因可能是表单设计者使用了:

'Windows' 风格在 Delphi 10.3 里约,所以 StyleServices.IsSystemStyle returns True

'Windows10' 风格 Delphi 10.4 Rio,所以 StyleServices.IsSystemStyle returns False

如此多的组件包受到该更改的影响,并更新了 .DFM 文件中的组件颜色。例如在 TMS VCL UI Pack 中到处都是这段代码 (LStyle.Name <> 'Windows')