got two quests>>

1)in my application,i have crated a notify icon...so now i want to do is that when the user click the close button,i want my app to minimize to system tray...how to do that??

2)how to add your own items in the windows shell context menu..like an anti virus..Scan With Norton...like that...

Thanks..

Here's an answer to the first question:

If you want to "exit" and stay in the system tray, trap FormClosing event

Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing

    ' Hide from taskbar
    Me.ShowInTaskbar = False
    ' Set window state to minimized
    Me.WindowState = FormWindowState.Minimized
    ' Cancel exit. Notice, you have to provide *some* way to exit app
    ' I would use a (global) boolean flag to indicate if we should exit or minimize to tray
    e.Cancel = True

  End Sub

If you want minimize to system tray, trap Resize event:

Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
    '
    If Me.WindowState = FormWindowState.Minimized Then
      Me.ShowInTaskbar = False
    End If

End Sub

I'm assuming you are already showing the notify icon. If not, add your show notify icon -code before "hiding the form".

Ok, your second question. AFAIK, it's very difficult to hook windows shell, and whatever language you're using, you'll need API calls to do that. There's no easy way. Try some googling for that topic. I've seen that question asked a few times but never seen a code how to do it :S

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.