1.TForm.Create(Self)的self是做什么用的?
2.form1 :=TForm.Create(Self);
form1 :=TForm.Create(nil);
上两创建时有什么区别,运行在表现在哪里不同?
2.form1 :=TForm.Create(Self);
form1 :=TForm.Create(nil);
上两创建时有什么区别,运行在表现在哪里不同?
解决方案 »
- 求一段正则表达式,采集URL
- 调用Delphi生成的DLL,退出程序后出现内存不能read!
- 关于拆分和循环比较的问题
- 一个小函数问题!
- 100分求DELPHI8的学习资料。UP有分
- TreeView中,如何捕捉到点击+、-符号事件,也就是展开、关闭事件?
- 关于TListView中的onColumnResize 事件
- 怎样是限制Edit里面输入的数在某个范围之内??比如0-999
- 现在用的控件都是D版的,以后怎么注册软件啊?
- 难题!!!!求解?
- 用delphi写了一个activexform,现在想让数据集通过网页的形式传给activexform,不知怎样读网页中的内容
- 应该不是难题,请各位帮忙
指定Owner为self指向的窗口,则self指向的窗口Free时由该窗口自动Free生成的form1。self也可以为当前的application。
form1 :=TForm.Create(nil);
未指定owner,得程序自己调用Free过程。
当为self时,需要通知当前form的所有组件,刚才的form已经创建了,并且可以不用手工释放,在self释放时,同时会释放其下属的刚创建的form的。如果你把刚创建的form手工释放的话,同样还会再通知self里的所有组件,它已经释放了。
在这一方面的的一般用法:如果生命周期很短的form,我会
with Tform.create(nil) do
try
ShowModal;
finally
Free;
end;
如果生命周期比较长的,比如在create时创建,destory时释放的窗体,我会create(application);
Operation: TOperation);
begin
inherited Notification(AComponent, Operation);
case Operation of
opInsert:
begin
if AComponent is TCustomActionList then
begin
if FActionLists = nil then FActionLists := TList.Create;
FActionLists.Add(AComponent);
end
else if not (csLoading in ComponentState) and (Menu = nil) and
(AComponent.Owner = Self) and (AComponent is TMainMenu) then
Menu := TMainMenu(AComponent);
end;
opRemove:
begin
if (FActionLists <> nil) and (AComponent is TCustomActionList) then
FActionLists.Remove(AComponent)
else
begin
if Menu = AComponent then Menu := nil;
if WindowMenu = AComponent then WindowMenu := nil;
if ObjectMenuItem = AComponent then ObjectMenuItem := nil;
end;
end;
end;
if FDesigner <> nil then
FDesigner.Notification(AComponent, Operation);
end;
这是来自vcl的代码。