ちょうど参考のために、次のコードを使用します。これは両方の回答が混在しています。 TFatalErrorAppEventsで
procedure SaveShowErrorMessage(...)
begin
with TFatalErrorAppEvents.Create(nil) do //avoid timer and further exceptions
try
Dialogs.MessageDlg(...);
finally
Free;
end;
end;
は、次のように:
type
TFatalErrorAppEvents = class(TApplicationEvents)
protected
procedure KillTimerMessages(var Msg: tagMSG; var Handled: Boolean);
procedure IgnoreAllExceptions(Sender: TObject; E: Exception);
public
constructor Create(AOwner: TComponent); override;
end;
constructor TFatalErrorAppEvents.Create(AOwner: TComponent);
begin
inherited;
OnMessage := KillTimerMessages;
OnException := IgnoreAllExceptions;
end;
procedure TFatalErrorAppEvents.IgnoreAllExceptions(Sender: TObject; E: Exception);
begin
//in case of an Exception do nothing here to ignore the exception
end;
procedure TFatalErrorAppEvents.KillTimerMessages(var Msg: tagMSG; var Handled: Boolean);
begin
if (Msg.message = WM_TIMER) then
Handled := True;
end;
は、私はメッセージのみがそのエラーダイアログに宛てていることが通過しますので、あなたは「最終的なエラーメッセージが表示されている」とAppのOnMsgインターセプトいくつかのグローバルフラグを持つべきだと思います、他のメッセージは除外されますhttp://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/delphivclwin32/Forms_TApplication_OnMessage.html –
'TTimer'を使用すると、すべての'ダイアログを表示する前に 'Application'のための' TTimer'(s)を実行してください。ちょっとした考え。 – kobik
@kobikその後、私のグローバル例外ハンドラはすべてのTTimerを認識する必要があります。私は他のソリューションを好む。 –