关于窗体的释放?(100分)

  • 主题发起人 主题发起人 子陵
  • 开始时间 开始时间

子陵

Unregistered / Unconfirmed
GUEST, unregistred user!
用Form.Free和在onClose中设置action:=caFree的效果是否一样?<br>我查看了源码,前者调用了destroy,前者调用了release<br>窗体关闭时的事件调用顺序是:close,release,destory,对吗?<br>procedure TCustomForm.Release;<br>begin<br>&nbsp; PostMessage(Handle, CM_RELEASE, 0, 0);<br>end;<br><br>destructor TCustomForm.Destroy;<br>begin<br>&nbsp; if not (csDestroying in ComponentState) then GlobalNameSpace.BeginWrite;<br>&nbsp; try<br>&nbsp; &nbsp; if OldCreateOrder then DoDestroy;<br>&nbsp; &nbsp; MergeMenu(False);<br>&nbsp; &nbsp; if HandleAllocated then DestroyWindowHandle;<br>&nbsp; &nbsp; Screen.RemoveForm(Self);<br>&nbsp; &nbsp; FCanvas.Free;<br>&nbsp; &nbsp; FIcon.Free;<br>&nbsp; &nbsp; FreeAndNil(FActionLists);<br>&nbsp; &nbsp; inherited Destroy;<br>&nbsp; finally<br>&nbsp; &nbsp; GlobalNameSpace.EndWrite;<br>&nbsp; end;<br>end;<br>release和destroy有什么不同?<br><br>
 
if not assigned(frmLock) then begin<br>&nbsp; &nbsp;frmLock := TfrmLock.Create(self);
 
标准方式: <br>&nbsp; if not assigned(frmstat) then<br>&nbsp; &nbsp; &nbsp; frmstat:=Tfrmstat.create(application);<br><br>&nbsp; &nbsp;frmstat.showmodal;<br>&nbsp; &nbsp;frmstat.free;<br>&nbsp; &nbsp;frmstat:=nil;
 
用Form.Free和在onClose中设置action:=caFree的效果是否一样?<br>窗体关闭时的事件调用顺序是:close,release,destory,对吗?<br>release和destroy有什么不同?<br><br><br><br>
 
Close:关闭而已,仅仅把此窗口隐含下来。<br>realse:它会等到FORM和FORM上的控件都完成了它们的事件后才Destory掉FORM<br>Destroy:将有FORM有关的内容从内存中移掉。
 
多人接受答案了。
 
后退
顶部