TApplication.CreateForm()方法与TForm.Create()的区别(50分)

  • 主题发起人 gwei_dfw
  • 开始时间
G

gwei_dfw

Unregistered / Unconfirmed
GUEST, unregistred user!
请问TApplication.CreateForm()方法与TForm.Create()的区别[:(]
 
论坛有讨论过,结论是大体没有区别。
看看这个过程:
procedure TApplication.CreateForm(InstanceClass: TComponentClass
var Reference);
var
Instance: TComponent;
begin
Instance := TComponent(InstanceClass.NewInstance);
TComponent(Reference) := Instance;
try
Instance.Create(Self);
except
TComponent(Reference) := nil;
raise;
end;
if (FMainForm = nil) and (Instance is TForm) then
begin
TForm(Instance).HandleNeeded;
FMainForm := TForm(Instance);
end;
end;
 
唯一的区别在于,TApplication.CreateForm()创建完窗体,如果没有主窗体,那么第一个通过该方法创建的窗体就被射为主窗体
 
应该是通过后面()中的参数来区别的
self,application
主要是区分创建的窗体的所属关系!
 
我是一个初学者,能告诉我,参数self,application的区别吗?
 
多人接受答案了。
 
顶部