dummzeuch 1505 Posted September 5, 2020 (edited) Does anybody know how to prevent the ExplicitTop/Left/Width/Height properties from being written to the DFM file? I never saw any use for them and always installed Andreas Hausladen's DDevExtensions which allows to remove them. But since Andy apparently doesn't have access to the latest Delphi version there is no DDevExtensions (and also no IDE Fix Pack) for Delphi 10.4(.1) and I would like to add that functionality to GExperts. I tried, but so far failed. Any hints? Edited September 5, 2020 by dummzeuch 1 Share this post Link to post
Mahdi Safsafi 225 Posted September 5, 2020 Delphi IDE uses System.Classes.TStream.WriteDescendentRes to serialize the form/components properties. Property that belongs to the class is handled by System.Classes.TWriter.WriteProperty. However internal property such ExplicitXxx is handled by System.Classes.TWriter.DefineProperty. // TPersistent.DefineProperties defines Explicit properties. and TWriter.DefineProperty encode them. procedure TControl.DefineProperties(Filer: TFiler); begin ... Filer.DefineProperty('IsControl', ReadIsControl, WriteIsControl, DoWriteIsControl); Filer.DefineProperty('ExplicitLeft', ReadExplicitLeft, WriteExplicitLeft, not (csReading in ComponentState) and DoWriteExplicit(edLeft)); Filer.DefineProperty('ExplicitTop', ReadExplicitTop, WriteExplicitTop, not (csReading in ComponentState) and DoWriteExplicit(edTop)); Filer.DefineProperty('ExplicitWidth', ReadExplicitWidth, WriteExplicitWidth, not (csReading in ComponentState) and DoWriteExplicit(edWidth)); Filer.DefineProperty('ExplicitHeight', ReadExplicitHeight, WriteExplicitHeight, not (csReading in ComponentState) and DoWriteExplicit(edHeight)); end; In a nutshell, hooking TWriter.DefineProperty will get you off EplicitXxx: procedure InterceptDefineProperty(Obj: TWriter; const Name: string; ReadData: TReaderProc; WriteData: TWriterProc; HasData: Boolean); begin // do nothing !!! or write a filter to allow certain ExplicitXxx. end; // install the hook : DefinePropertyPtr := GetProcAddress(GetModuleHandle('rtl260.bpl'), '@System@Classes@TWriter@DefineProperty$qqrx20System@UnicodeStringynpqqrp22System@Classes@TReader$vynpqqrp22System@Classes@TWriter$vo'); @TrampolineDefineProperty := InterceptCreate(DefinePropertyPtr, @InterceptDefineProperty); 2 2 Share this post Link to post
David Schwartz 426 Posted September 6, 2020 What are they used for? I could never tell why they even started showing up. Share this post Link to post
dummzeuch 1505 Posted September 6, 2020 1 hour ago, David Schwartz said: What are they used for? I could never tell why they even started showing up. In theory they are used to preserve the original size and position of controls when they are set to alClient, alTop etc. so when they are set back so alNone at a later time, they automatically revert to their original size and position. Personally I never found that useful and since these values tend to change very often (no idea why, they shouldn't) they pollute the DFM diffs and history. 1 1 Share this post Link to post
David Schwartz 426 Posted September 6, 2020 I've never figured out why they change so often either. And with or without them, in the rare cases where I select None for an alignment, it usually just leave the object in the same place and dimensions. I don't care if it reverts back to something else or not. Share this post Link to post
Fr0sT.Brutal 900 Posted September 6, 2020 I apparently saw some expert allowing to exclude some properties from saved DFM... maybe CnPack? I haven't tried too much experts so if not GExperts then it should be CnPack Share this post Link to post
Stefan Glienke 2003 Posted September 7, 2020 Here is the explanation: http://jedqc.blogspot.com/2006/02/d2006-what-on-earth-are-these-explicit.html 1 Share this post Link to post
luebbe 26 Posted September 7, 2020 @dummzeuch, With TortoiseSVN you could implement a local pre-commit hook that removes the Explicit properties from all or just the modified .dfm files. We do this to normalize .dproj files before commit. 1 Share this post Link to post
DaSteMpO 0 Posted September 24, 2020 (edited) On 9/5/2020 at 11:46 PM, Mahdi Safsafi said: procedure InterceptDefineProperty(Obj: TWriter; const Name: string; ReadData: TReaderProc; WriteData: TWriterProc; HasData: Boolean); begin // do nothing !!! or write a filter to allow certain ExplicitXxx. end; // install the hook : DefinePropertyPtr := GetProcAddress(GetModuleHandle('rtl260.bpl'), '@System@Classes@TWriter@DefineProperty$qqrx20System@UnicodeStringynpqqrp22System@Classes@TReader$vynpqqrp22System@Classes@TWriter$vo'); @TrampolineDefineProperty := InterceptCreate(DefinePropertyPtr, @InterceptDefineProperty); Thanks, that really helped me much developing an own plugin (using rtl270.bpl for D10.4.1) Edited September 24, 2020 by DaSteMpO Share this post Link to post
Lars Fosdal 1792 Posted September 25, 2020 I freaking loathe those explicit... props. Whoever introduced them should have had all their key caps removed. 1 Share this post Link to post
Bill Meyer 337 Posted September 25, 2020 46 minutes ago, Lars Fosdal said: I freaking loathe those explicit... props. Whoever introduced them should have had all their key caps removed. Not a fan of them, either, but I recognize the reasons they were added. There were also some attempts long ago to implement form scaling, for which the explicits would be helpful. Or would, if such scaling were practical. But it's not (see rounding errors) since we would need all visuals dimensioned in floating point to make that work. Share this post Link to post
Achim Kalwa 61 Posted September 28, 2020 I know I am late to the party, but you might try the attached package for Delphi 10.4.1. It uses the hooking code from Andreas Hausladen's VclFixPack v1.4 to patch the TControl.DefineProperties method to a modified code, which does not write those Explicit* properties to the DFM file. Unpack the zip archive, open DControlsFix.dpk in Delphi 10.4.1, compile & install. There is nothing to customize. If this package is installed, the patch is active. If you like to get the default behaviour back, just uninstall the package. Use at your own risk 😉 DControlsFix.zip 2 7 Share this post Link to post
DaSteMpO 0 Posted October 1, 2020 On 9/5/2020 at 1:19 PM, dummzeuch said: Does anybody know how to prevent the ExplicitTop/Left/Width/Height properties from being written to the DFM file? I never saw any use for them and always installed Andreas Hausladen's DDevExtensions which allows to remove them. But since Andy apparently doesn't have access to the latest Delphi version there is no DDevExtensions (and also no IDE Fix Pack) for Delphi 10.4(.1) and I would like to add that functionality to GExperts. I tried, but so far failed. Any hints? Did you succeed in integrating it into GExperts? Share this post Link to post
dummzeuch 1505 Posted October 1, 2020 7 hours ago, DaSteMpO said: Did you succeed in integrating it into GExperts? No, didn't try yet. And with @Achim Kalwa's plugin, available (which I haven't tried yet either), I'm not sure I'll bother. Share this post Link to post
Bill Meyer 337 Posted October 1, 2020 50 minutes ago, dummzeuch said: No, didn't try yet. And with @Achim Kalwa's plugin, available (which I haven't tried yet either), I'm not sure I'll bother. We're not all on 10.4.1..... Share this post Link to post
Achim Kalwa 61 Posted October 1, 2020 In fact first attempt was to integrate this little patch into GExperts. There is already GX_VCLFixPack.pas, which is a slightly modified version of Andreas' VclFixPack.pas. It is currently not in use (disabled by $IFDEF) and needs some cleanup, e.g. remove unused and old Win95 code 🙂. But for a "complete" GX Expert it would be neccessary to have at least an on/off configuration switch in the IDE settings section; but I did not dig deep enough to implement such a thing. And some kind of documentation would be helpful, too. Maybe I'll find some spare time at the weekend for creating a patch to GExperts. 1 Share this post Link to post
Achim Kalwa 61 Posted October 1, 2020 23 minutes ago, Bill Meyer said: We're not all on 10.4.1..... For those on older Delphi versions, there is still Andreas "DDevExtensions", which offers a function to disable the Explicit*-properties when saving the DFM file: https://www.idefixpack.de/blog/ide-tools/ddevextensions/ 1 Share this post Link to post
Tommi Prami 130 Posted October 3, 2020 On 9/28/2020 at 7:11 PM, Achim Kalwa said: I know I am late to the party, but you might try the attached package for Delphi 10.4.1. It uses the hooking code from Andreas Hausladen's VclFixPack v1.4 to patch the TControl.DefineProperties method to a modified code, which does not write those Explicit* properties to the DFM file. Unpack the zip archive, open DControlsFix.dpk in Delphi 10.4.1, compile & install. There is nothing to customize. If this package is installed, the patch is active. If you like to get the default behaviour back, just uninstall the package. Use at your own risk 😉 DControlsFix.zip Works! Thnaks,. Share this post Link to post
dummzeuch 1505 Posted December 26, 2020 On 10/1/2020 at 10:45 PM, Achim Kalwa said: Maybe I'll find some spare time at the weekend for creating a patch to GExperts. I just converted your code into an expert in revision #3418 3 Share this post Link to post
Hallvard Vassbotn 3 Posted February 18, 2021 On 9/28/2020 at 6:11 PM, Achim Kalwa said: DControlsFix.zip Great, thanks! 🙂 Share this post Link to post
Ian Branch 127 Posted February 18, 2021 Hi Guys, I am late to the party here.. Can someone explain what the issue/problem is? How would it manifest itself to me? Why is it good to remove it? i.e. what benefit does it give me? Regards & TIA, Ian Share this post Link to post
dummzeuch 1505 Posted February 19, 2021 (edited) 19 hours ago, Ian Branch said: Can someone explain what the issue/problem is? How would it manifest itself to me? Why is it good to remove it? i.e. what benefit does it give me? ... and other older posts in this topic. Edited February 19, 2021 by dummzeuch Share this post Link to post
Attila Kovacs 629 Posted February 20, 2021 (edited) forget it, must be something else. Edited February 20, 2021 by Attila Kovacs Share this post Link to post