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?
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.