我正在系统托盘通知区域中运行应用程序,但问题是虽然我退出应用程序时图标仍然存在,但当我将鼠标指向通知区域附近时它已经消失,因为当我点击退出时它应该是。我想这是因为我的鼠标位置会使区域刷新,如果是这样,我怎么能在我的应用程序中执行它以避免在那里使用无用的图标?
先谢谢
答案 0 :(得分:2)
关闭应用程序时,应丢弃托盘图标 要么明确
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
NotifyIcon1.Dispose()
End Sub
或者最好是设计师在您不编辑代码时自动执行
在InitializeComponent
Me.components = New System.ComponentModel.Container()
Me.NotifyIcon1 = New System.Windows.Forms.NotifyIcon(Me.components)
然后是表单的dispose方法
<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