Tray Icon issue

L

Lothar Behrens

Hi,

I have read some articles that argue using a timer (I am using all 5
seconds) will avoid disapearing of the tray icon for the application.
Yesterday it worked, but after increasing the version number and
installing it, it disapears again.

I do not understand this. I don't like to tell my users to go to tray
configuration to set my application not to hide the inactive icons and
using the timer seemed a reasonable solution.

I even always change the icon instance as seen in the code below.

How to do it correctly?

Thanks

Lothar

Icon loadIcon(string path)
{
try
{
FileStream stream;
stream =
File.OpenRead(System.AppDomain.CurrentDomain.BaseDirectory + "\\" +
path);
Icon icon1 = new Icon(stream);
return icon1;
}
catch
{
// Handle error
return ((System.Drawing.Icon)
(resources.GetObject("notifyIconMainApplication.Icon")));
}
}

private void trayIconActive_Tick(object sender, EventArgs e)
{
notifyIconMainApplication.Icon = loadIcon(onlineIcon);
}
 
J

Jeff Gaines

How to do it correctly?

Either don't do it, users are able to set up which icons to display and
will get annoyed if you override that.
Or provide a link in your program to the System Icons control panel applet.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top