Delphi 5 中的 ApplicationHandleException 变量?
ApplicationHandleException variable in Delphi 5?
我正在尝试使用 AsyncCalls
,假设 也适用于 Delphi 5。
如果我注释 call/use ApplicationHandleException
类 变量 Delphi 5 没有的行(我不确定什么时候它也被介绍过)。
procedure TThreadPool.MainThreadWndProc(var Msg: TMessage);
begin
try
...
except
if Assigned(ApplicationHandleException) then
ApplicationHandleException(Self);
end;
end;
我几乎确定在Delphi 5 上面应该是:
try
...
except
Application.HandleException(Self);
end;
但不确定如何处理此代码:
destructor TInternalAsyncCall.Destroy;
begin
...
// TAsyncCall.Destroy either already called Sync() or we are a "forgotten" async call
// and we need to handle the exception ourself by trying to throw it in the main thread
// or just ignoring it.
if FFatalException <> nil then
begin
if Assigned(ApplicationHandleException) and // <---
(ThreadPool.FMainThreadVclHandle <> 0) and IsWindow(ThreadPool.FMainThreadVclHandle) then
PostMessage(ThreadPool.FMainThreadVclHandle, WM_RAISEEXCEPTION, WPARAM(FFatalErrorAddr), LPARAM(FFatalException))
else
FFatalException.Free;
end;
inherited Destroy;
end;
Delphi 5 中正确的 "translation" 是什么?我应该简单地忽略这个变量,因为它不存在吗?请指教
在 TApplication.Create
中有这段代码分配给 ApplicationHandleException
变量。
if not Assigned(System.Classes.ApplicationHandleException) then
System.Classes.ApplicationHandleException := HandleException;
现在 HandleException
实际上是 Self.HandleException
,当你允许隐式 Self
目标时。
所以是的,你可以替换:
if Assigned(ApplicationHandleException) then
ApplicationHandleException(Self);
和
if Assigned(Application) then
Application.HandleException(Self);
一般来说,对于 Delphi 5,你会替换
Assigned(ApplicationHandleException)
和
Assigned(Application)
几乎总是 Assigned(Application)
的计算结果为 True
,但您可能在非 VCL 设置中工作,或者代码可能在全局 Application
之前执行对象创建或销毁后。
我正在尝试使用 AsyncCalls
,假设 也适用于 Delphi 5。
如果我注释 call/use ApplicationHandleException
类 变量 Delphi 5 没有的行(我不确定什么时候它也被介绍过)。
procedure TThreadPool.MainThreadWndProc(var Msg: TMessage); begin try ... except if Assigned(ApplicationHandleException) then ApplicationHandleException(Self); end; end;
我几乎确定在Delphi 5 上面应该是:
try
...
except
Application.HandleException(Self);
end;
但不确定如何处理此代码:
destructor TInternalAsyncCall.Destroy; begin ... // TAsyncCall.Destroy either already called Sync() or we are a "forgotten" async call // and we need to handle the exception ourself by trying to throw it in the main thread // or just ignoring it. if FFatalException <> nil then begin if Assigned(ApplicationHandleException) and // <--- (ThreadPool.FMainThreadVclHandle <> 0) and IsWindow(ThreadPool.FMainThreadVclHandle) then PostMessage(ThreadPool.FMainThreadVclHandle, WM_RAISEEXCEPTION, WPARAM(FFatalErrorAddr), LPARAM(FFatalException)) else FFatalException.Free; end; inherited Destroy; end;
Delphi 5 中正确的 "translation" 是什么?我应该简单地忽略这个变量,因为它不存在吗?请指教
在 TApplication.Create
中有这段代码分配给 ApplicationHandleException
变量。
if not Assigned(System.Classes.ApplicationHandleException) then
System.Classes.ApplicationHandleException := HandleException;
现在 HandleException
实际上是 Self.HandleException
,当你允许隐式 Self
目标时。
所以是的,你可以替换:
if Assigned(ApplicationHandleException) then
ApplicationHandleException(Self);
和
if Assigned(Application) then
Application.HandleException(Self);
一般来说,对于 Delphi 5,你会替换
Assigned(ApplicationHandleException)
和
Assigned(Application)
几乎总是 Assigned(Application)
的计算结果为 True
,但您可能在非 VCL 设置中工作,或者代码可能在全局 Application
之前执行对象创建或销毁后。