Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Tray icon will not go away!

3 views
Skip to first unread message

george d lake

unread,
Jan 6, 2004, 11:13:20 AM1/6/04
to
Hi,
I have an app that runs in the system tray. When I exit the app (from a
button on a form) the app ends but the icon stays in the tray.
Any ideas?

here is the code I use to end the app

Me.Close()

Me.Hide()

m_trayIcon.Icon = Nothing

End


Mike Bulava

unread,
Jan 6, 2004, 11:21:15 AM1/6/04
to
Set the Visable property of the NotifyIcon to false when your application is
closing.. Setting it to Nothing doesn't just make it go away..


"george d lake" <gero...@cuartel15.com> wrote in message
news:ewCkBAH1...@TK2MSFTNGP10.phx.gbl...

george d lake

unread,
Jan 6, 2004, 11:27:45 AM1/6/04
to
Ok, I changed it to:

m_trayIcon.Visible = False
End

and iut still stays there. I have to mouseover it in order for it to go
away.

"Mike Bulava" <mbu...@comcast.net> wrote in message
news:u81YXEH1...@TK2MSFTNGP11.phx.gbl...

Herfried K. Wagner [MVP]

unread,
Jan 6, 2004, 11:26:45 AM1/6/04
to
* "george d lake" <gero...@cuartel15.com> scripsit:

Set the icon's 'Visible' property to 'False' before closing the form.

> End

Why do you use 'End' here?!

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Steven Van Dalem

unread,
Jan 6, 2004, 11:40:59 AM1/6/04
to
Change the order of you statements:
m_trayIcon.Visible = False
m_trayIcon = Nothing
Me.Hide()
Me.Close()

It's not a good idea to put statements after Me.Close(). If you do it that
way, you have to wait for GC to clean up after you, because m_trayIcon has
gone out of scope

Steven

"george d lake" <gero...@cuartel15.com> wrote in message

news:eC9HFIH1...@tk2msftngp13.phx.gbl...

george d lake

unread,
Jan 6, 2004, 11:43:16 AM1/6/04
to
Its part of a function that ends the app when a button is clicked. I do not
want to use the "X" from the form. Is there a better way of doing this?

"Herfried K. Wagner [MVP]" <hirf-spa...@gmx.at> wrote in message
news:uTvzENH1...@TK2MSFTNGP11.phx.gbl...

Armin Zingler

unread,
Jan 6, 2004, 12:28:31 PM1/6/04
to
"george d lake" <gero...@cuartel15.com> schrieb

> Its part of a function that ends the app when a button is clicked. I
> do not want to use the "X" from the form. Is there a better way of
> doing this?


There are *only* better ways of doing this.

SCNR

(Sorry, I don't write more - Herfried will *g*)


--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Herfried K. Wagner [MVP]

unread,
Jan 6, 2004, 6:40:03 PM1/6/04
to
* "george d lake" <gero...@cuartel15.com> scripsit:
> Its part of a function that ends the app when a button is clicked. I do not
> want to use the "X" from the form. Is there a better way of doing this?

Pass a reference to the form instance and call its 'Close' method.

Jay B. Harlow [MVP - Outlook]

unread,
Jan 6, 2004, 10:01:23 PM1/6/04
to
George,
In addition to the others comments.

If your app a Form that happens to have a system tray icon. Or a System Tray
icon that happens to have a form?

In my app, which happens to be a System Tray icon that happens to have a
Form, I had to explicitly call Dispose on the Component where the NotifyIcon
was located, which indirectly caused Dispose to be called on the NotifyIcon.

Note the NotifyIcon was located in a class derived from Component. This
component was my startup object. It had a Shared Sub Main that created a new
instance of the component, then called Application.Run with no parameters.

Elsewhere in my program I would create an instance of a form and call
ShowDialog to show it, based on a Menu click event, the component owned the
Menu & NotifyIcon...

Hope this helps
Jay

"george d lake" <gero...@cuartel15.com> wrote in message
news:ewCkBAH1...@TK2MSFTNGP10.phx.gbl...

0 new messages