Balloon hints on Delphi app tray icon keep popping up indefinitely
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 f开发者_JS百科or 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?
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;
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;
精彩评论