10

我想创建一个从 Windows 右下角系统托盘运行的程序。

但我不知道从哪里开始?

有人可以告诉我在哪里看和示例或使用什么命令来研究吗?

4

3 回答 3

19

NotifyIcon在主窗口窗体中添加一个。使用Resize事件 inForm来控制何时显示NotifyIcon和隐藏表单:

Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
        If Me.WindowState = FormWindowState.Minimized Then
                NotifyIcon1.Visible = true
                Me.Hide()
                NotifyIcon1.BalloonTipText = "Hi from right system tray"
                NotifyIcon1.ShowBalloonTip(500)
        End If
    End Sub

使用 NotifyIcon 中的事件再次显示表单:

Private Sub NotifyIcon1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles NotifyIcon1.DoubleClick
        Me.Show()
        Me.WindowState = FormWindowState.Normal
        NotifyIcon1.Visible = False
    End Sub

您可以在AutoDNIE谷歌代码项目中下载完整示例

于 2013-08-07T10:15:23.420 回答
14

我查看了我注意到错过图标的答案。

Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
    If Me.WindowState = FormWindowState.Minimized Then
        NotifyIcon1.Visible = True
        NotifyIcon1.Icon = SystemIcons.Application
        NotifyIcon1.BalloonTipIcon = ToolTipIcon.Info
        NotifyIcon1.BalloonTipTitle = "Verificador corriendo"
        NotifyIcon1.BalloonTipText = "Verificador corriendo"
        NotifyIcon1.ShowBalloonTip(50000)
        'Me.Hide()
        ShowInTaskbar = False
    End If
End Sub

Private Sub NotifyIcon1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles NotifyIcon1.DoubleClick
    'Me.Show()
    ShowInTaskbar = True
    Me.WindowState = FormWindowState.Normal
    NotifyIcon1.Visible = False
End Sub
于 2015-05-25T16:39:39.170 回答
1

你也可以这样做:

Sub ToggleHide()
    If Me.WindowState = FormWindowState.Normal Then
        Me.ShowInTaskbar = False
        Me.WindowState = FormWindowState.Minimized
    Else
        Me.ShowInTaskbar = True
        Me.WindowState = FormWindowState.Normal
    End If
End Sub
于 2013-08-07T11:58:11.487 回答