Tray icon doesn't disappear after making it invisible

  • Thread starter Thread starter Bry
  • Start date Start date
B

Bry

Sorry for the repost, but this has been driving me mad for the past few
days. There must be a simple solution.

There are many other posts about this problem upon an application exit,
but my problem is slightly different as my application does exit.......

I have a tray icon that wont disappear after calling

trayIcon.visible = false;

I have to move my mouse over the icon, and only then will it close. I'm
guessing the icon has actually gone, but the system tray just needs a
refresh.

Is there an easy way of doing this?
 
Sorry for the repost, but this has been driving me mad for the
past few days. There must be a simple solution.

There are many other posts about this problem upon an
application exit, but my problem is slightly different as my
application does exit.......

I have a tray icon that wont disappear after calling

trayIcon.visible = false;

I have to move my mouse over the icon, and only then will it
close. I'm guessing the icon has actually gone, but the system
tray just needs a refresh.

Is there an easy way of doing this?

Bry,

Are you exiting the app from w/i an IDE (i.e. by pressing the
IDE's "stop" button)? Or does this behavior happen when the app is
exited normally?


Chris.
 
Neither. The app is still running, all I want to do is make the tray
icon disappear, leaving the app still running.

The icon is set as invisible, but needs the user to hover over the icon
for it to disappear. Is there a way of getting the OS to refresh the
contents of the system tray?
 
Neither. The app is still running, all I want to do is make the
tray icon disappear, leaving the app still running.

The icon is set as invisible, but needs the user to hover over
the icon for it to disappear. Is there a way of getting the OS
to refresh the contents of the system tray?

Bry,

I can't reproduce that behavior on my system:

.Net 1.1
VS.Net 2003
Windows XP SP2

I created a small WinForms test app with a button and a NotifyIcon.
I put this code in the button's click event handler:

private void button1_Click(object sender, System.EventArgs e)
{
this.notifyIcon1.Visible = !this.notifyIcon1.Visible;
}

The tray icon behaves as expected - appearing and disappearing each
time the button is pressed.

One thought that comes to mind is threading. Are you trying to make
the tray icon invisible from within a thread?

Chris.
 
Ah-ha! Thanks Chris, I think you have found the problem. My application
does indeed use threading and I'm pretty sure that a worker thread is
setting the visible property.

Many Thanks.
Bry.
 
Ah-ha! Thanks Chris, I think you have found the problem. My
application does indeed use threading and I'm pretty sure that a
worker thread is setting the visible property.

Bry,

You may already know this, but in order for a worker thread to update
a WinForms control, the thread has to be launched via the form's
Invoke (synchronous) or BeginInvoke (asynchronous) methods.


Chris.
 
Back
Top