Presence of the situation: two packages: "Base" and "Descendant" and the application "Example". The base package and the Example application can be in the same project group, but the Descendant package must be in the other project group without any Base and Example source code.
The purpose of such manipulations is to hide the sources of the database and applications from employees who will work with the Descendant package.
The basic package contains the form: TFormBase with some components and some code. I create it and get some binaries: bpl, dcp, etc.
type TFormBase = class(TForm) Panel1: TPanel; BOk: TButton; BCancel: TButton; procedure BOkClick(Sender: TObject); procedure BCancelClick(Sender: TObject); private protected function GetOkButtonCaption: string; virtual; function GetCancelButtonCaption: string; virtual; public end; implementation {$R *.dfm} procedure TFormBase.BCancelClick(Sender: TObject); begin ShowMessage('"' + GetCancelButtonCaption + '" button has been pressed'); end; procedure TFormBase.BOkClick(Sender: TObject); begin ShowMessage('"' + GetOkButtonCaption + '" button has been pressed'); end; function TFormBase.GetCancelButtonCaption: string; begin Result := 'Cancel'; end; function TFormBase.GetOkButtonCaption: string; begin Result := 'Ok'; end;
Descendant package contains TFormDescendant = class (TFormBase)
type TFormDescendant = class(TFormBase) private protected function GetOkButtonCaption: string; override; function GetCancelButtonCaption: string; override; public end; implementation {$R *.dfm} function TFormDescendant.GetCancelButtonCaption: string; begin Result := 'Descendant Cancel'; end; function TFormDescendant.GetOkButtonCaption: string; begin Result := 'Descendant Ok'; end;
And the Descendant.dfm code:
inherited FormDescendant: TFormDescendant Caption = 'FormDescendant' end
Descendant.dpr:
requires rtl, vcl, Base; contains Descendant in 'Descendant.pas' {FormDescendant};
When creating a FormDescendant, it should look like FormBase because it is just inherited from it. And we can add some other components to this kind of saving FormBase FormDescendant.
But when we try to open the FormDescendant in the Delphi IDE, it crashes with "Error creating form: Ancestor for" TFormBase "not found." And that's right: Base.bpl contains only binary code, and Delphi does not know what TBaseForm looks like during development.
What to do to open FormDescendant in Delphi?
I read How to use or resolve visual form inheritance problems in Delphi? and Register a custom form so that I can inherit it from several projects without copying the form to the object repository folder. But these tips did not help. Is there a way to open a FormDescendant at design time without TFormBase sources?
Here are examples of experiment examples: http://yadi.sk/d/IHT9I4pm1iSOn