Delphi - Why does ExplicitWidth and ExplicitHeight keep appearing in .DFM files and what is it?

扶醉桌前 提交于 2019-12-29 06:34:11

问题


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

回答1:


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.




回答2:


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




回答3:


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.



来源:https://stackoverflow.com/questions/2476690/delphi-why-does-explicitwidth-and-explicitheight-keep-appearing-in-dfm-files

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!