开发者

Old instances of application in system tray notification area

开发者 https://www.devze.com 2023-02-11 08:09 出处:网络
I am having an applciation running in system tray notification area, but the problem is that although I exit the application the icon is still there, when I point my mouse near notification area it\'s

I am having an applciation running in system tray notification area, but the problem is that although I exit the application the icon is still there, when I point my mouse near notification area it's gone as it should be when I clicked on exit. I guess it is because my mouse position makes the area to refresh, if so, how can I do it inside my application to av开发者_如何转开发oid having my useless icon in there?

Thanks in Advance


When you close your application you should dispose your tray icon Either explicitly

Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
    NotifyIcon1.Dispose()
End Sub

or preferably as the designer does automatically if you don't edit the code

In InitializeComponent

Me.components = New System.ComponentModel.Container()
Me.NotifyIcon1 = New System.Windows.Forms.NotifyIcon(Me.components)

and then the dispose method of the form

<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
    Try
        If disposing AndAlso components IsNot Nothing Then
            components.Dispose()
        End If
    Finally
        MyBase.Dispose(disposing)
    End Try
End Sub
0

精彩评论

暂无评论...
验证码 换一张
取 消