1

I have a D2006 app that notifies various events via a tray balloon hint. Every so often, but not very often - say 1 in 10 invocations of the app -, one of the hints decides it is going to popup again and again... forever. The only thing that stops it is to close the app.

If the app issues another balloon int, it replaces the phantom hint, but then after the new hint times out, the phantom hint returns. Likewise if I close the phantom hint it returns immediately.

I've verified that the code to create the hint is not being called repeatedly. The hint is originating deeper in the bowels somewhere.

    MainForm.TrayIcon1.BalloonFlags   := Flag ;
    MainForm.TrayIcon1.BalloonTitle   := Title ;
    MainForm.TrayIcon1.BalloonHint    := Message ;
    MainForm.TrayIcon1.BalloonTimeout := Delayms ;
    MainForm.TrayIcon1.ShowBalloonHint ;
rossmcm
  • 5,493
  • 10
  • 55
  • 118
  • How are you popping the hints? How are you hiding the hints when they time out? Seeing some code might help us spot an error. For one, without code, all I can say is "You probably have an error in your app". – Cosmin Prund Mar 08 '11 at 13:04
  • @Cosmin. See edits. I'm not hiding the hints explicitly. I assume the expiry of the timeout closes and diposes. – rossmcm Mar 08 '11 at 19:53
  • This won't help you, but I had this problem with Delphi 2006 and just gave up - I couldn't find a solution. I'm sure it is a bug somewhere, but it definitely wasn't in my code. I think it was not a problem on Windows XP, but it definitely was on Windows 7. – Misha Mar 08 '11 at 23:42
  • Hi @Misha. It's WinXP I have the problem on. Haven't seen it yet on Win7 – rossmcm Mar 08 '11 at 23:45
  • someone here (http://stackoverflow.com/questions/902642/how-to-hide-a-taskbar-balloon-at-will) suggested setting the szInfo member of the NOTIFYICONDATA to contain an empty string. I tried that - it closes the balloon but it just opens again straight away. – rossmcm Mar 08 '11 at 23:52
  • Maybe it was XP rather than 7 that caused the problem - it was a while ago now and I removed the balloon hints totally because I did not need them. If you do find an answer I will be interested to know what it was, because I never solved this issue! – Misha Mar 09 '11 at 00:23
  • possible duplicate of [Balloon hints on Delphi app tray icon keep popping up indefinitely](http://stackoverflow.com/questions/4192178/balloon-hints-on-delphi-app-tray-icon-keep-popping-up-indefinitely) – Wim Coenen Mar 25 '12 at 11:57

2 Answers2

5

Make a common entry point for the balloon hint. i.e. a wrapper function. Along with the text to display, include another string parameter called WhereCalledFrom, and use that to identify which part of your app is calling the hint.
Within the wrapper, log all hint calls (to a .txt file, GExperts debugger, Windows Output Debug String, Windows Event Log, etc..) to log the date/time, WhereCalledFrom, and the message. That should let you track this down pretty easily.

Chris Thornton
  • 15,620
  • 5
  • 37
  • 62
  • I've already established that the routine is not being called again when these phantom hints appear. – rossmcm Mar 08 '11 at 19:54
0

You may want to try to turn off automatic balloon closing and let you application do it e.g. set a timer when you show a balloon and then when the timer expires, close the balloon.

On top of this, (i have had similar issues in c# - i think its more a windows thing rather than IDE specific), and one of the solutions was to manually force the tray icon to invisible then visible i.e.

TrayIcon1.Visible := false;
TrayIcon1.Visible := true;

So when you manually hide the balloon icon, run the above code to 'cleanse' the system tray. This may stop the 'phantom' baloon hint. Just something to try.

Simon
  • 9,197
  • 13
  • 72
  • 115
  • I'll certainly try that and report back - When you say "turn off automatic balloon closing" - All I am doing is: MainForm.TrayIcon1.BalloonTimeout := Delayms ; MainForm.TrayIcon1.ShowBalloonHint ; and I expect the hint to close after the delay - which it does - and then it pops up again - so I'm not hopeful that toggling the Visible property will work, but I'll try it. – rossmcm Mar 10 '11 at 03:43
  • I havent got Delphi2006, but is there a way to programmatically close the balloon (or alternatively an OnCloseBalloon event) (or hide the tray just before the delayms value)? Thats what i was referring to. Probably a longshot, but worth a try. Obviously if you hide the icon while the balloon is visible then it will hide the balloon. – Simon Mar 10 '11 at 04:50
  • I've been closing the balloon by calling the routine with an empty string and a delay of zero. It works - for a short while! - then it pops up again. – rossmcm Mar 10 '11 at 05:18