procedure TBaseThread.DoHandleException; begin // 关闭当前主窗体对鼠标的响应 if GetCapture $#@60;$#@62; 0 then SendMessage(GetCapture, WM_CANCELMODE, 0, 0); // 判定异常的范围并做相应处理 if FException is Exception then Application.ShowException(FException) else SysUtils.ShowException(FException, nil); ... end;
procedure TBaseThread.HandleException; begin //得到当前异常对象 FException := Exception(ExceptObject); try //避免因 EAbort 消息使程序推出 if not (FException is EAbort) then Synchronize(DoHandleException); finally FException := nil; end; end;
procedure TMyThread.Execute; begin ... end;
procedure TMyThread.HandleException; begin
... end;
procedure TForm1.RunThread; begin //为 TMyThread 类创建实例 with TMyThread.Create(True) do begin FreeOnTerminate := True; Resume; end; end; ...