Base包和Example应用程序可以位于一个项目组中,但Descendant包必须位于其他项目组中,而不包含Base和Example的任何源代码.
这种 *** 作的目的是隐藏将使用Descendant包的工人的Base和Application源.
Base包包含一个表单:TFormBase,包含一些组件和一些代码.我构建它并获得一些二进制文件:bpl,dcp等…
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;
后代包包含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;
和Descendant.dfm的代码:
inherited FormDescendant: TFormDescendant Caption = 'FormDescendant'end
Descendant.dpr:
requires rtl,vcl,Base;contains Descendant in 'Descendant.pas' {FormDescendant};
在创建FormDescendant时,它应该看起来像FormBase,因为它只是从它继承而来.我们可以在这个FormDescendant上添加一些其他组件来保存FormBase外观.
但是当我们尝试在Delphi IDE中打开FormDescendant时,它会崩溃“创建表单时出错:’找不到’TFormBase’的祖先’.”
这是正确的:Base.bpl只包含二进制代码,而Delphi不知道TBaseForm在设计时的外观.
如何在Delphi中打开FormDescendant?
我读过How do I use or resolve issues with visual form inheritance in Delphi?和Register custom form so I can inherit from it from multiple projects,without copying the form to the Object Repository folder
但那些建议没有帮助.
有没有办法在没有TFormBase源的情况下在设计时打开FormDescendant?
以下是实验示例的项目:http://yadi.sk/d/IHT9I4pm1iSOn
解决方法 您可以提供一个存根单元(某些)实现代码被剥离,只有.dfm和接口必须相同.这就是Allen Bauer在他的 Opening Doors文章中所做的工作,展示了如何实施 dockable IDE forms.然后,您的开发人员需要先打开存根表单元,然后才能打开后代表单.
总结以上是内存溢出为你收集整理的表单 – 在Delphi XE2中没有源代码的另一个包中的基本表单的可视继承全部内容,希望文章能够帮你解决表单 – 在Delphi XE2中没有源代码的另一个包中的基本表单的可视继承所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)