unit dForm;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;type
TLHBForm = class(TForm)
private
{ Private declarations }
protected
{ Protected declarations }
public
{ Public declarations }
published { Published declarations }
end;procedure Register;implementationprocedure Register;
begin
RegisterComponents('setup', [TLHBForm]);
end;
end.
控件编写如上:
当我动态创建一个窗体时,即pform :=TLHBForm.Create(Application)
程序运行报错,请问是什么原因?
不知是否需要添加继承Tform的create,destroy方法。
...implementation//注意加上这一句
{$R *.dfm}...
还是不行,我的油箱[email protected]
将你做好的给我看看,谢谢!
我看了看VCL的源码
如果FORM不是TFORM
而是其他从Tcustomform下继承的
包括tcustomform本身的话
在create里只要检查出类名不是tform就要查找
相应的dfm资源如果没有就会报这个错
用常规方法实现不了
如果用registerclass和createwindow
api来实现或许可以一试
你的这个TLHBForm要放到Tfrom上吗?
TA =class(TForm)
end;
var
A :TA;
procedure TForm1.Button1Click(Sender: TObject);
begin
A :=TForm.CreateParented(Handle);
A.Show;
end;