为什么有的窗体可以调用release,有的则没有此过程。?

解决方案 »

  1.   

    DescriptionUse Release to destroy the form and free its associated memory.Release is much like the Free method except that Release does not destroy the form until all event handlers of the form and event handlers of components on the form have finished executing. Any event handlers of the form should use Release instead of Free. Failing to do so could lead to an access violation.
      

  2.   

    Release等窗体所有事件都执行完成了再释放窗体
    free不管事件的执行就立即释放窗体
      

  3.   

    释放一个窗体实例时,直接Free可能不够安全,因为当你想释放某个窗体实例时,这个窗体还有一些消息需要处理,
    应该使用Release
    Release其实非常简单。它的好处在于能够把窗体应该处理完的消息处理后再释放。//发一个消息通知自己要释放
    procedure TCustomForm.Release;
    begin
      PostMessage(Handle, CM_RELEASE, 0, 0);
    end;//具体处理也仅仅是调用Free
    procedure TCustomForm.CMRelease;
    begin
      Free;
    end;