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; ...