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);
}
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);
}