This workaround will allow your DataModule to be created anyway, by intercepting and ignoring errors about the non-existent TForm properties Delphi is inserting in your dfm (this is just a workaround, not a solution to the IDE problem you are experiencing)
1) Add these declarations to your datamodule class:
private
FSaveReaderOnError:TReaderError;
procedure OnReaderError(Reader: TReader; const Message: string; var Handled: Boolean);
protected
procedure ReadState(Reader: TReader); override;
The ReadState method we are overriding is responsible of loading the DFM and it does it using the Reader:TReader object.
TReader exposes an event handler we can intercept to ignore errors:
procedure TMyDataModule.ReadState(Reader: TReader);
begin
FSaveReaderOnError := Reader.OnError;
try
// install our error handler
reader.OnError := self.OnReaderError;
// let the dfm loading continue
inherited;
finally
// restore previous error handler
Reader.OnError := FSaveReaderOnError;
FSaveReaderOnError := nil;
end;
end;
This is a the error handler:
procedure TMyDataModule.OnReaderError(Reader: TReader; const Message: string; var Handled: Boolean);
var Ignora:boolean;
tmp:string;
begin
if Assigned(FSaveReaderOnError) then begin
// in case there already was an error handler, we call if first
FSaveReaderOnError(Reader,Message,Handled);
if handled = true then
exit;
end;
// ignore errors about missing form properties
if not message.StartsWith('Error reading '+self.name) then exit;
if not message.EndsWith(' does not exist') then exit;
if not message.Contains(' Property ') then exit;
Handled := true;
if message.Contains('Font') then exit;
if message.Contains('ClientHeight') then exit;
if message.Contains('ClientWidth') then exit;
if message.Contains('Color') then exit;
if message.Contains('PixelsPerInch') then exit;
if message.Contains('TextHeight') then exit;
Handled := false;
end;
DSServerModule1
doesn't have a property namedClientHeight
. Or perhapsCliehtHeight
. Looks like you didn't use the clipboard which is always a slight worry. It would help if we knew whatDSServerModule1
was. Instead of trying to change the .dfm file at random without understanding what you are doing, it would be prudent to diagnose the problem first. We cannot see the .dfm file and we have no idea what it contains or what type your object is. – David Heffernan