Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TrayIcon Issue

Status
Not open for further replies.

majlumbo

Programmer
Jul 13, 2010
295
US
I have a trayicon that displays when an event happens within my application, and I also have a balloon tip that comes up from it when the icon is first made visible. I also have a timer that is enabled at that point, and if the user doesn't address the issue within 10 minutes, I redisplay the balloon tip.

When I exit the application, if the trayicon is visible, I make trayicon.visible := false. It's difficult to reproduce the error, but I think only if the balloon tip is showing, when I attempt to exit the program I get the error.. Cannot Remove System Shell Notification Icon

I also have a memory leak reported, and an EOutofResources error (which I think is associated with the timer)

I can't seem to find anyway of manually making the balloon tip disappear from the trayicon before closing to see if that will solve my problem. Any ideas on how to do this, or has anyone else had problems with the TrayIcon component?
 
I assume this is the one in Delphi and not any one else's?

It is not possible for anyone to acknowledge truth when their salary depends on them not doing it.
 
Yes, it is the TrayIcon that comes standard in Delphi 2006.
 
I tried pushing the TTrayIcon in Delphi 2006 along with the TTimer in the way described and didn't get any errors. I also looked at the TTrayIcon code and it looks pretty reasonable in terms of memory allocation (window handles, icons).

The second thing sounds like a memory allocation issue, to be sure, so to ask: How are you using TTrayIcon? Are you creating it/destroying it, or are you using it as a VCL Control?

As for the first, this likely happens when the data representing the icon gets corrupted. Be sure you are not doing anything to overwrite the data you have representing the icon or any of the data representing the message link your application has to the icon.

It is not possible for anyone to acknowledge truth when their salary depends on them not doing it.
 
There's actually quite a lot going on with this trayicon. One, it is an animated icon, so I have it attached to an imagelist. I also have a popup menu attached to it, I also have the ondblclick attached to its method. Basically, either double clicking or through the popup menu it refreshes a display with up to date information (the icon informs the user that his data is no longer up to date). During the refresh, I change the balloon tip, redisplay it, and then when finished, remove the icon.

I don't get the memory leak, or the outofresources error, if I go forward with the refresh, only when I close the program while the animated icon is still being displayed with the balloon tip(but again, only intermittently - it just isn't consistent). The strange thing is that at the end of my refresh process, I simply set the trayicon.visible to false if it is being displayed, which is the same thing that happens when I close the program. When I do a refresh, I don't get the error, when I exit the application, I sometimes get the error.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top