I need to implement almost the same interface in several projects. I want to create a base form class with immutable components, and then in the application make a form inheriting from this class, adding the necessary components (and inheriting the "base").
I create a module "my_form" in which I write:
{ TCommonForm }
TCommonForm = class(TForm)
procedure FormCreate(Sender : TObject);
private
public
end;
In the main module, I do this:
{ TForm1 }
TForm1 = class(TCommonForm)
procedure FormCreate(Sender : TObject);
private
public
end;
and
procedure TForm1.FormCreate(Sender : TObject);
begin
inherited;
end;
This code compiles fine, the call to the inherited FormCreate method is done, the visual form editor works - everything is fine as intended. But this only works until IDE is closed or my project is closed. If I try to open this project with this description of my form, IDE hangs and then falls.
How can I properly inherit my form from my class, and not from the standard class TForm, in order to keep the form visually editable in the editor?
I am assuming that IDE and the compiler run at different times, so it would be possible to use the conditional compilation directives {$if}-{$else}, but this requires having a predefined macro that exists for "IDE"-time and does not exist for the compiler-time, for example:{$if defined(IS_IDE_WORK)} // do not work!!! I figured it out later and corrected the message.
TForm1 = class(TForm)
{$else}
TForm1 = class(TCommonForm}
{$endif}
Is there such a predefined macro?