locked
how to minimize to tray and maximize window RRS feed

  • Question

  • Hi ,I dont know how to minimize my program to try  and be able to open context menu ( close option) on right mouse click on program icon when in try statusbar ; and maximize it when doubleclicked with left mouse button , could someone help me ?
    Thursday, January 8, 2009 10:40 AM

Answers

  • Ok a quick example, Have a notifyicon and set its icon property, add contextmenustrip and add a menuitem called close

    Public Class Form1  
        Private Sub Form1_Load(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles MyBase.Load  
            Me.ShowInTaskbar = False 
            NotifyIcon1.ContextMenuStrip = ContextMenuStrip1  
        End Sub 
     
        Private Sub CloseToolStripMenuItem_Click(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles CloseToolStripMenuItem.Click  
            Application.Exit()  
        End Sub 
        Private Sub Form1_Resize(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles MyBase.Resize  
            If Me.WindowState = FormWindowState.Minimized Then 
                Me.Hide()  
            End If 
        End Sub 
        Private Sub NotifyIcon1_DoubleClick(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles NotifyIcon1.DoubleClick  
            Me.Show()  
            Me.WindowState = FormWindowState.Normal  
        End Sub 
    End Class 


    Arjun Paudel
    • Marked as answer by cesno Friday, January 9, 2009 11:09 AM
    Thursday, January 8, 2009 11:19 AM

All replies

  • Ok a quick example, Have a notifyicon and set its icon property, add contextmenustrip and add a menuitem called close

    Public Class Form1  
        Private Sub Form1_Load(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles MyBase.Load  
            Me.ShowInTaskbar = False 
            NotifyIcon1.ContextMenuStrip = ContextMenuStrip1  
        End Sub 
     
        Private Sub CloseToolStripMenuItem_Click(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles CloseToolStripMenuItem.Click  
            Application.Exit()  
        End Sub 
        Private Sub Form1_Resize(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles MyBase.Resize  
            If Me.WindowState = FormWindowState.Minimized Then 
                Me.Hide()  
            End If 
        End Sub 
        Private Sub NotifyIcon1_DoubleClick(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles NotifyIcon1.DoubleClick  
            Me.Show()  
            Me.WindowState = FormWindowState.Normal  
        End Sub 
    End Class 


    Arjun Paudel
    • Marked as answer by cesno Friday, January 9, 2009 11:09 AM
    Thursday, January 8, 2009 11:19 AM
  • thanks nice post ;)
    Thursday, January 8, 2009 8:11 PM