NotifyIcon Doesn't Disappear When Program Closes

P

Phil Galey

VB.NET 2002 on Windows 2000 SP 3

When I start my program, the NotifyIcon appears in the tray, as it should.
However, when I close the program, the NotifyIcon remains until I hover over
it with my mouse. If I don't hover over it to make it disappear and then
open the program again, another one is added, resulting in a multiplicity of
the icon in the tray.

I've even tried setting its Visible property to false, followed by a call to
the Dispose method of the NotifyIcon in the Form1_Closing event, but the
NotifyIcon still remains when the program closes.

How can I get the NotifyIcon to disappear when I close my program? Thanks.
 
P

Phil Galey

I had previously attempted that method, i.e. explicitly referencing and
removing the icon from the tray. However, I was unable to determine how to
reference it. Do you know how it can be referenced? The word "Simply"
certainly sounds encouraging. Thanks.
 
N

news.sbcglobal.net

VB.Net:

Protected Overrides Sub OnClosing(ByVal e As
System.ComponentModel.CancelEventArgs)

YourTrayIcon.Visible = False

YourTrayIcon.dispose 'propably don't need this.

End Sub
 
P

Phil Galey

Oh ... yea. That's what I did, as indicated in my initial posting (see
below). I thought you were saying you knew of a way of directly accessing
and removing icons in the System Tray.

But I think I discovered why NotifyIcon1.Visible = False in the OnClosing
event wasn't working. I was quitting the program from the VB.NET
development environment, so it wasn't triggering the OnClosing event.

Anyway, thanks.
 

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

Similar Threads


Top