A quick way to remove properties from .dfm files in Delphi

冷暖自知 提交于 2019-12-05 02:23:36

Try this tool Delphi DFM properties remover, works with old versions of delphi but maybe can help you.

One possible approach is to modify your component so that it is capable of simply ignoring these properties. That way you don't have to hunt them down in each and every .dfm file.

For example:

type
  TIgnoreFormPropertyHelper = class
  public
    class procedure IgnoreBooleanProperty(Reader: TReader);
    class procedure IgnoreIntegerProperty(Reader: TReader);
  end;

{ TIgnoreFormPropertyHelper }

class procedure TIgnoreFormPropertyHelper.IgnoreBooleanProperty(Reader: TReader);
begin
  Reader.ReadBoolean;
end;

class procedure TIgnoreFormPropertyHelper.IgnoreIntegerProperty(Reader: TReader);
begin
  Reader.ReadInteger;
end;

type
  TMyComponent = class(...)
  ....  
  protected
    procedure DefineProperties(Filer: TFiler); override;
  ....  

procedure TMyComponent.DefineProperties(Filer: TFiler);
begin
  inherited;
  Filer.DefineProperty('MyLegacyBooleanProperty',
    TIgnoreFormPropertyHelper.IgnoreBooleanProperty, nil, False);
  Filer.DefineProperty('MyLegacyIntegerProperty',
    TIgnoreFormPropertyHelper.IgnoreIntegerProperty, nil, False);
end;

The Jedi VCL contains a tool called DFMCleaner:

DFMCleaner is a tool to remove unsupported properties from DFMs. If you save a dfm file in one version of Delphi and want to use it in an earlier version, chances are there are some unsupported properties in it, generating an error when the form is opened in Delphi. What's even worse, if the dfm is part of a design-time package, Delphi will install the package without errors but when you try to access the form at design-time (f ex if the form is used by a property editor), Delphi generates an AV instead.

It is located in jvcl-install\devtools\DFMCleaner (project with source code and example configuration file)

In my case simply closing the project and deleting the DProj file helped.

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