类问题 write the code in TParentForm 's OnDestory event as : self:=nil then the TchildForm will inherit this statement and execute 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 对,在父类的OnDestroy中写self := nil就行了如在子类的OnDestroy有别的动作,在用一下Inherited 我原来就用这方法的,但得不到所要的结果(Assigned(ChildFormX)仍然还是返回TRUE) 欧,刚才试了一下,确实不好使,想了一下,可能是这个原因吧在TParentForm.Destroy(Sender: TObject)中编译器在执行期是加了一个self参数,只是加了一个当前实例引用的一拷贝值,如果self是变量参数的话,我想就应该行了,呵呵,但不行不知有没有别的方法 如果self为拷贝值的话,这好像不符面向对象原理 我是这个意思,好像编译器在运行时对于TParentForm.Destroy加一Self即为TParentForm.OnDestroy(Sender: TObject;Self: TParentForm);好像是这样子而此时当它的子类释放时,当调用OnDestroy时,则调用祖先的OnDestroy,而此时的Self对应的是子类实例,但这时的参数为数值参数,只是把参数Self的值改为nil,而实例仍然未改如果是这样子,就好了TParentForm.OnDestroy(Sender: TObject;var Self: TParentForm); to xzgyb 很感谢你 我知道你的意思,那能不能用什么编译器开关来改变呢 有了,你试一试,在TParentForm中写这几句TParentForm = class(TForm) procedure FormClose(Sender: TObject; var Action: TCloseAction); private FInstance : ^TForm; public constructor Create(AOwner:TComponent; var FRef:TForm); destructor Destroy;override;end;implementationconstructor TParentForm.Create(AOwner:TComponent; var FRef: TForm);begin FInstance := @FRef; Inherited Create(AOwner);end;destructor TParentForm.Destroy;begin Inherited; FInstance^ := nil;end;procedure TParentForm.FormClose(Sender: TObject; var Action: TCloseAction);begin Action := caFree;end;以后创建子窗口就ChildForm1 := TChildForm1(Application, ChildForm1);OK?,好用可要加分呀,呵呵 写错了创建子窗口时应为ChildForm1 := TChildForm1.Create(Application, TForm(ChildForm1)); to xzgyb这方法很好,加分是肯定的可惜我代码已经完成了,就差这项功能,所以去修改所有子窗体的Create函数,有点麻烦如果事先就用你这方法的法,倒是很好。不知道大家还有没别的方法,只要修改父类就可 创建时先判断form是否为nilif form=nil then application.createform(tform,form);form.show;or form.showmodal;在form的onclose事件中加action:=cafree;form:=nil; to snjun你说的没错,不过我想把这些代码放入父类中实现 不改Create参数你就将FInstance : ^TForm放到public中,在Create语句后赋值即可。也可以做成可写属性呵呵。如果不放心是否每个Create都改了程序,在FormCreate中加Assert断言判断。 delphi 模糊查询(输入字母后出现小窗体,并根据字母过滤) 纯粹郁闷散分 report machine 如何做交叉报表 关于Delphi使用ACTIVE SKIN的问题 关于delphi中文件的使用问题,请高手指点! 最简单的问题,很急. ADO连接oracle得奇怪问题,能够解决的肯定是高手~~~ 在win98下装DCOM是不是先要装补丁程序? 请推荐串口通讯控件(能在Delphi5中使用)!!!!谢谢!!! 有谁做了二进制显示的控件,最好有源代码 今日第三问,用Table能否实现表的连结查询。。。 急急急!midas+socketconnection的服务器端首次运行实际做哪些配置?
如在子类的OnDestroy有别的动作,在用一下Inherited
在TParentForm.Destroy(Sender: TObject)中
编译器在执行期是加了一个self参数,只是加了一个当前实例引用
的一拷贝值,如果self是变量参数的话,我想就应该行了,呵呵,但不行
不知有没有别的方法
即为TParentForm.OnDestroy(Sender: TObject;Self: TParentForm);
好像是这样子
而此时当它的子类释放时,当调用OnDestroy时,则调用祖先的OnDestroy,而此时的Self对应
的是子类实例,但这时的参数为数值参数,只是把参数Self的值改为nil,而实例仍然未改
如果是这样子,就好了
TParentForm.OnDestroy(Sender: TObject;var Self: TParentForm);
我知道你的意思,那能不能用什么编译器开关来改变呢
TParentForm = class(TForm)
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
FInstance : ^TForm;
public
constructor Create(AOwner:TComponent; var FRef:TForm);
destructor Destroy;override;
end;implementation
constructor TParentForm.Create(AOwner:TComponent; var FRef: TForm);
begin
FInstance := @FRef;
Inherited Create(AOwner);
end;
destructor TParentForm.Destroy;
begin
Inherited;
FInstance^ := nil;
end;
procedure TParentForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caFree;
end;以后创建子窗口就
ChildForm1 := TChildForm1(Application, ChildForm1);
OK?,好用可要加分呀,呵呵
创建子窗口时应为ChildForm1 := TChildForm1.Create(Application, TForm(ChildForm1));
这方法很好,加分是肯定的
可惜我代码已经完成了,就差这项功能,所以去修改所有子窗体的Create函数,有点麻烦
如果事先就用你这方法的法,倒是很好。
不知道大家还有没别的方法,只要修改父类就可
先判断form是否为nil
if form=nil then
application.createform(tform,form);
form.show;or form.showmodal;
在form的onclose事件中加
action:=cafree;
form:=nil;
你说的没错,不过我想把这些代码放入父类中实现