12

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?

Dani Rodríguez
  • 72
  • 3
  • 13
rossmcm
  • 5,493
  • 10
  • 55
  • 118
  • check if you have a timer that calls the tray icon to display the balloon or better yet search the entire project for the name of the tray icon component and see where do you call the procedure that shows the balloon. –  Nov 16 '10 at 08:41
  • @Dorin. Thanks, done that. The code that assigns to the BalloonHint property of the TTrayIcon is definitely not being called again. – rossmcm Nov 16 '10 at 09:22
  • are you testing this on Windows XP? I seem to remember there was a bug with the balloons provided by MS on that OS. Anyway, check the accepted answer at http://stackoverflow.com/questions/902642/how-to-hide-a-taskbar-balloon-at-will. I think that might help you. – Guillem Vicens Feb 27 '11 at 06:49
  • Is it your own apps ? If yes could you post the code to check it. Simply relying on your explanation without seeing the source code it is very difficult to give an answer. – HpTerm Jan 24 '12 at 18:11
  • 2
    Did you ever resolve this? If so you should put your solution as an answer. – Kenneth Cochran Mar 27 '12 at 15:18
  • Just for reference because it all is WM_NOTIFY anyway: http://stackoverflow.com/questions/1078179/windows-and-hints-in-delphi – HX_unbanned May 21 '12 at 12:33

2 Answers2

3

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;  
A1rPun
  • 16,287
  • 7
  • 57
  • 90
0

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;
Martin
  • 1,184
  • 8
  • 24
  • Hard to see how this relates to the question which concerned a Delphi application – David Heffernan Oct 24 '14 at 14:06
  • It's a solution for the same problem. Only in different code. Translate my one-line of code into a Delphi code. Would that be a problem for the OP? – Martin Oct 28 '14 at 13:11