如何在Delphis MessageDlg中忽略计时器事件 [英] How to ignore timer events in Delphis MessageDlg

查看:97
本文介绍了如何在Delphis MessageDlg中忽略计时器事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Delphi中设置了一个全局异常处理程序。在某些严重的异常情况下,将显示一条错误消息(紧随其后的是Halt())。当显示错误消息时,Delphi正在处理消息队列,处理计时器事件,这会导致进一步的错误。

I have set up a global exception handler in Delphi. On some severe exceptions an error message is displayed (followed by Halt()). While the error message is shown, Delphi is processing the message queue, processing timer events, that lead to further errors.

我要显示的是一个错误对话框不处理计时器事件。

What I want is to show an error dialog which does not process timer events. How is that possible in Delphi?

编辑:我用Dialogs.MessageDlg(...)显示消息。

I use Dialogs.MessageDlg(...) to display the message.

推荐答案

您可以使用 WM_TIMER http://docwiki.embarcadero.com/Libraries/zh-CN/Vcl.Forms.TApplication.OnMessage rel = nofollow> TApplication.OnMessage

You can filter queued messages, such as WM_TIMER, with TApplication.OnMessage.

procedure TMainForm.ApplicationMessage(var Msg: TMsg; var Handled: Boolean);
begin
  if ShowingFatalErrorDialog then
    if Msg.Message = WM_TIMER then
      Handled := True;
end;

直接将事件处理程序分配给 Application.OnMessage 或使用 TApplicationEvents 对象。

Either assign that event handler directly to Application.OnMessage or use a TApplicationEvents object.

显然,您必须为<$ c $提供实现c> ShowingFatalErrorDialog ,但我相信这样做很明显。

Obviously you'll have to provide the implementation for ShowingFatalErrorDialog but I trust that it is obvious to you how to do so.

这篇关于如何在Delphis MessageDlg中忽略计时器事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆