我做了一个窗体(窗体1): 这里窗体1: 一直是处在打开状态. 又做了别外 一个窗体(窗体2)。 窗体2: 调用 窗体1 : 方法:在窗体2 onshow 事件时用定义一个变量a:窗体1: 变量a := 窗体1.Create(Application); 变量a.Parent :=窗体2; 在关闭 窗体后。判断 原来打开的窗体1 是否存在: 我用Assgin(窗体1) 来判断.. .... 结果这个返回的结果是False;
为什么窗体1 是打开的。 结果是Fasle
为什么窗体1 是打开的。 结果是Fasle
var P: Pointer;begin
P := nil;
if Assigned (P) then Writeln ('You won''t see this');
GetMem(P, 1024); {P valid}
FreeMem(P, 1024); {P no longer valid and still not nil}
if Assigned (P) then Writeln ('You''ll see this');
end;
Delphi syntax:function Assigned(const P): Boolean;DescriptionUse Assigned to determine whether the pointer or procedure referenced by P is nil. P must be a variable reference of a pointer or procedural type. Assigned(P) corresponds to the test P<> nil for a pointer variable, and @P <> nil for a procedural variable.Assigned returns false if P is nil, true otherwise.Note: Assigned can't detect a dangling pointer--that is, one that isn't nil but no longer points to valid data. For example, in the code example for Assigned, Assigned won't detect the fact that P isn't valid.
Form2:=TForm2.Create(Application);
Form2.ShowModal;也可以使用变量var a:TForm2; 则把上面的Form2改成a即可; 根据此道理自己去改吧;