9
votes

I have recently modified one of my components, and it so happens it is no longer using one of the properties it used before.

However, those properties are written in multiple .dfm files throughout the project. Now, when i try to compile the project, i get "Error reading .: Property <...> does not exist"

The complicated part is that the property value is binary data (stored in multiple lines), and i cant just delete it with Delphi replace or notepad++ regexp (since they are single-line based).

So my question would be:

Are there any third party tools or ways to easily remove properties from multiple .dfm files?

4
if you open your dfm and save it again, invalid property is not removed? looks strange..teran
@teran The problem is opening the .dfm file in the first place. The streaming code will object at the .dfm file read point.David Heffernan
@DavidHeffernan I thought IDE asks to 'ignore' or 'remove' incorrect property with binary fields. For ex: I place TAdvGlowButton (from TMS) to the form, then I replace field definition in form class (button1 : TButton), after I open form as text (alt+f12), and replace TAdvGlowButton to TButton (of course TMS button has more properties than standart). So, now DFM has invalid properties. if I try to open form, IDE asks "Ignore the error and continue?", and if I press Ok, then invalid properties are deleted.teran
@teran Maybe I'm remembering from the old days. I always just make my component able to deal with it all silently.David Heffernan

4 Answers

9
votes

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

4
votes

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;
1
votes

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)

0
votes

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