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.
Release等窗体所有事件都执行完成了再释放窗体 free不管事件的执行就立即释放窗体
释放一个窗体实例时,直接Free可能不够安全,因为当你想释放某个窗体实例时,这个窗体还有一些消息需要处理, 应该使用Release Release其实非常简单。它的好处在于能够把窗体应该处理完的消息处理后再释放。//发一个消息通知自己要释放 procedure TCustomForm.Release; begin PostMessage(Handle, CM_RELEASE, 0, 0); end;//具体处理也仅仅是调用Free procedure TCustomForm.CMRelease; begin Free; end;
free不管事件的执行就立即释放窗体
应该使用Release
Release其实非常简单。它的好处在于能够把窗体应该处理完的消息处理后再释放。//发一个消息通知自己要释放
procedure TCustomForm.Release;
begin
PostMessage(Handle, CM_RELEASE, 0, 0);
end;//具体处理也仅仅是调用Free
procedure TCustomForm.CMRelease;
begin
Free;
end;