Delphi 应用程序托盘图标上的气球提示不断弹出

发布于 2024-10-02 06:58:59 字数 290 浏览 8 评论 0原文

我有一个 Delphi 2006 应用程序,可以最小化为托盘图标,并通过托盘图标上的气球提示显示各种警报消息。

在某些情况下 - 我不知道什么时候 - 先前显示的气球提示会不断弹出并且不会消失。它会显示设定的时间长度,关闭,然后立即重新出现。

它始终是来自此应用程序的气球提示。

如果应用程序显示另一个气球提示(该提示在编程的时间内显示),则虚拟提示将恢复。

就好像提示被困在队列中的某个地方并且不会被删除。在没有人有灵感的情况下(我意识到这是一个渺茫的机会......),有人知道如何清除气球提示吗?

I have a Delphi 2006 app that can minimize to a tray icon, and displays various alert messages via a balloon hint over the tray icon.

Under some circumstances - I don't know when - a previously displayed balloon hint keeps popping up and won't go away. It displays for the length of time programmed, closes, then immediately reappears.

It is always a balloon hint from this app.

If the app displays another balloon hint, that one shows for the programmed time, then the phantom hint resumes.

It is as if the hint is stuck in a queue somewhere and doesn't get removed. In absence of anyone with some inspiration (I realise it's a long shot...), does anyone know how to purge the balloon hints?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

失与倦" 2024-10-09 06:58:59

您使用哪个 TrayIcon? “Vcl.ExtCtrls”中的TCustomTrayIcon使用TNotifyIconData将Popup发送到TrayIcon。某些属性需要 Windows Vista 或更高版本。

public
  FData: TNotifyIconData; //Winapi.ShellAPI

procedure TCustomTrayIcon.ShowBalloonHint;
begin
  FData.uFlags := FData.uFlags or NIF_INFO;
  FData.dwInfoFlags := Cardinal(FBalloonFlags);
  Shell_NotifyIcon(NIM_MODIFY, FData); //Refresh(NIM_MODIFY);
end;

您可以通过处理托盘图标发送的消息来查看正在发生的情况。

NIN_BALLOONSHOW      = WM_USER + 2;
NIN_BALLOONHIDE      = WM_USER + 3;
NIN_BALLOONTIMEOUT   = WM_USER + 4;
NIN_BALLOONUSERCLICK = WM_USER + 5;  

Which TrayIcon are you using? The TCustomTrayIcon in "Vcl.ExtCtrls" uses TNotifyIconData to send the Popup to the TrayIcon. Some properties require Windows Vista or later.

public
  FData: TNotifyIconData; //Winapi.ShellAPI

procedure TCustomTrayIcon.ShowBalloonHint;
begin
  FData.uFlags := FData.uFlags or NIF_INFO;
  FData.dwInfoFlags := Cardinal(FBalloonFlags);
  Shell_NotifyIcon(NIM_MODIFY, FData); //Refresh(NIM_MODIFY);
end;

You can see whats going on by handling messages send by the trayicon.

NIN_BALLOONSHOW      = WM_USER + 2;
NIN_BALLOONHIDE      = WM_USER + 3;
NIN_BALLOONTIMEOUT   = WM_USER + 4;
NIN_BALLOONUSERCLICK = WM_USER + 5;  
中二柚 2024-10-09 06:58:59

我在 VB.NET 中也遇到同样的问题。我的应用程序通过系统托盘中的气球提示显示错误消息。当同时出现多个错误时,气球提示会坚持正常超时并一个接一个地显示错误。看起来有某种缓冲区可以记住您尝试显示气球提示的实际次数。如果您停止显示新的气球提示并等待足够长的时间,它最终会停止。

我的目标是在另一个气球出现时立即关闭当前的气球提示,但我还没有想出办法。所以这只是解决方案的一半。


[添加完整解决方案]

完整解决方案非常简单。在显示新的气球提示之前执行此操作(其中 Tray 是您的 TrayIcon/NotifyIcon)。

Tray.Visible = true;

I'm facing the same problem in VB.NET. My application shows error messages through a balloontip in the systray. When there are multiple errors at once the balloontip sticks to it's normal timeout and shows the errors one after another. It looks like there is some sort of buffer that remembers the actual number of times you try to show the balloontip. If you stop showing new balloontips and wait long enough it would eventually stop.

My goal would be to close the current balloontip as soon as another one comes in, but i haven't figured out to do it yet. So this is only half a solution.


[Added full solution]

The full solution was very simple. Do this before showing a new balloontip (Where Tray is your TrayIcon/NotifyIcon).

Tray.Visible = true;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文