Delphi - Why does ExplicitWidth and ExplicitHeight keep appearing in .DFM files and what is it?
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
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
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.
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.
I encounter a lot of noise from random (dis)appearances of these:
ExplicitLeft = 0
ExplicitTop = 0
ExplicitWidth = 0
ExplicitHeight = 0
So I wrote a tool that removes only these (all 4 exist and are 0) from DFM files:
https://github.com/gonutz/dfm_clear_explicit_zeros
精彩评论