要使.NET应用程序在Window的系统托盘中显示为图标,需要做些什么?
你如何处理所述图标上的鼠标按钮点击?
首先,添加NotifyIcon控件到窗体.然后连接通知图标以执行您想要的操作.
如果你希望它最小化隐藏到托盘,试试这个.
Private Sub frmMain_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Resize
If Me.WindowState = FormWindowState.Minimized Then
Me.ShowInTaskbar = False
Else
Me.ShowInTaskbar = True
End If
End Sub
Private Sub NotifyIcon1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseClick
Me.WindowState = FormWindowState.Normal
End Sub
我偶尔会使用气球文本来通知用户 - 这样做是这样的:
Me.NotifyIcon1.ShowBalloonTip(3000, "This is a notification title!!", "This is notification text.", ToolTipIcon.Info)
您可以将工具箱中的NotifyIcon组件添加到主窗体中.
这包含可用于处理各种事件的MouseDoubleClick等事件.
编辑:如果您希望它在系统托盘中正确显示,您必须确保将Icon属性设置为有效的.ico文件.