delphi 和 vcl 中的几个问题
鼓捣delphi一年多了,以为对delphi 有一定的熟悉了 今天才发现原来什么都不知道,以下应该都是简单问题,但就是没明白,等搞明白了 我散分给大家
1. Application 是在Form单元中声明的Tapplication 型变量,这个东东是在什么
地方实例化的 Application.Initialize 做了些什么事情
2.以下是Tapplication.CreateForm的代码
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;
2.1 var Reference 没有说明类型是怎么回事 从来没有见过好像也没有哪本书提到过
2.2 Instance := TComponent(InstanceClass.NewInstance) 难道不是实例化了一个Tcomponent对象吗?如果不是那他是干什么的?
2.3 Instance.Create(Self) 这一句该如何解释? 变量不能自己实例化自己啊 不明白
2.4 TComponent(Reference) := Instance; 这个是什么意思啊 ?