Balloon hints on Delphi app tray icon keep popping up indefinitely
Asked Answered
H

2

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?

Howlan answered 16/11, 2010 at 8:10 Comment(6)
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.Conni
@Dorin. Thanks, done that. The code that assigns to the BalloonHint property of the TTrayIcon is definitely not being called again.Howlan
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 #903142. I think that might help you.Whitethroat
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.Vulpine
Did you ever resolve this? If so you should put your solution as an answer.Thirza
Just for reference because it all is WM_NOTIFY anyway: https://mcmap.net/q/1012522/-windows-and-hints-in-delphiServiceable
M
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;  
Madonia answered 11/6, 2012 at 19:5 Comment(0)
M
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;
Mallarme answered 24/10, 2014 at 12:54 Comment(2)
Hard to see how this relates to the question which concerned a Delphi applicationDrown
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?Mallarme

© 2022 - 2024 — McMap. All rights reserved.