65.9K
CodeProject is changing. Read more.
Home

Minimize Form in System Tray

starIconstarIconstarIconemptyStarIconemptyStarIcon

3.00/5 (4 votes)

Feb 13, 2010

CPOL
viewsIcon

34201

Note that you must select NotifyIcon1 from the ToolBox and set any icon to its icon property plus make 3 buttons or you can write minimize to tray code in the form closing event.Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As...

Note that you must select NotifyIcon1 from the ToolBox and set any icon to its icon property plus make 3 buttons or you can write minimize to tray code in the form closing event.
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles Button1.Click
        Me.WindowState = FormWindowState.Minimized
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles Button2.Click
        Application.Exit()
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles Button3.Click
        Me.WindowState = FormWindowState.Minimized
        Me.Visible = False
        NotifyIcon1.Visible = True
    End Sub

    Private Sub NotifyIcon1_MouseDoubleClick(ByVal sender As System.Object, _
        ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseDoubleClick
        Me.Visible = True
        Me.WindowState = FormWindowState.Normal
        NotifyIcon1.Visible = False
    End Sub
End Class