tags:

views:

491

answers:

4

We've noticed that when checking in updates that our .DFM files have had ExplicitWidth and ExplicitHeight properties added for what appears to be no particular reason.

My two questions are, what are they for and why do they get automatically added by Delphi?

Below is an example with the property in:

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

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.

Dmitry
I just listed TcxSplitter as an example that I had to hand. It most commonly happens with TForm.
Pauk
+2  A: 

I think these properties are another Delphi mystery, just like the EProgrammerNotFoundException ...

mjustin
+7  A: 

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.

JamesB
They're the dimensions that you *explicitly* gave them, as opposed to the dimensions that they acquired *implicitly* due to alignment or anchoring. They're not necessarily the *original* dimensions, which you might have changed between the time you created the control and the time you set its alignment.
Rob Kennedy
This sounds plausible, but it isn't what actually happens: In my experience the Delphi IDE switches between storing the same values in Left/Right/Width/Height an their ExplicitXxx counterparts every time the form gets written to the .dfm. The same applies to the ItemHeight property of a TComboBox which changes between 0 and 13 and back all the time. It gets quite annoying when my source control wants to post changes to the .dfm all the time when nothing actually has changed.
dummzeuch
Same happens here, using Delphi 2009, all the time, this is not my favorite waste of time.
mjustin
+9  A: 

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

André
+1. I don't use it for compatibilty reasons but just to keep my DFMs smaller and the source control diffs less cluttered.
Ulrich Gerhardt
-1. Does not answer the question.
Rob Kennedy
I like this, since like Ulrich, it removes it from bugging us on source code updates. Wish I could split the answer between both this and JamesB's answer!
Pauk