Delphi - Why does ExplicitWidth and ExplicitHeight

2019-01-25 01:58发布

We've noticed that when checking in updates, our .DFM files have added ExplicitWidth and ExplicitHeight properties - but we don't know why.

My questions are:

  • What are these properties for?
  • Why are they automatically added by Delphi?

Below is an example showing the added ExplicitWidth property:

object Splitter2: TcxSplitter
    Left = 0
    Top = 292
    Width = 566
    Height = 8
    Cursor = crVSplit
    HotZoneClassName = 'TcxXPTaskBarStyle'
    AlignSplitter = salBottom
    Control = BottomPanel
    Color = clBtnFace
    ExplicitWidth = 8
end

标签: delphi dfm
3条回答
淡お忘
2楼-- · 2019-01-25 02:09

Delphi adds value of published properties to DFM file only when its value different from default.

For example:

property ExplicitWidth: Integer read FExplicitWidth write FExplicitWidth default 1;

If ExplicitWidth value is not 1 then it will be written to the DFM. When the "default" is not defined then any value will be written to the DFM.

TcxSplitter is not standard Delphi component, you'd better ask its author about the purpose of the properties.

查看更多
Emotional °昔
3楼-- · 2019-01-25 02:17

With DDevExtensions you can disable storing these properties in the dfm:
http://andy.jgknet.de/blog/?page_id=10

Adds Explicit* property remover to keep DFM files compatible to older Delphi versions

查看更多
男人必须洒脱
4楼-- · 2019-01-25 02:22

From Googling....

Original article can be found here.

The Explicit properties remember the previous bounds of a control before the Align or Anchor properties are changed from their defaults.

The only time the Explicit properties are not written is when the Align property is set back to its default value of alNone.

This is when the Explicit properties are actually used by the control to reset its bounds to what it was previously.

查看更多
登录 后发表回答