Who can help me set up a contextmenu for tray icon
Hello,
Can somebody help me creat a tray icon contextmenu, so when you right click the icon the
menu appears. Also, when an item is clicked on the menu,
the tray icon's form will appear or disappear?
I have the following code for the problem but it does not seem to do much.
thanks,
Bruce
Sub Createcontextmenu()
Dim ctx As New ContextMenu()
With ctx.MenuItems
.Add(New MenuItem("Click to Restore Form", AddressOf icnContext_Click))
.Add(New MenuItem("Click to Minimize Form", AddressOf icnContext_Click))
.Add(New MenuItem("Exit", AddressOf icnContext_Click))
End With
icnContext.ContextMenu = ctx
End Sub
Private Sub icnContext_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim mi As MenuItem = DirectCast(sender, MenuItem)
Select Case mi.Text
Case "Click to Restore Form"
Me.Visible() = True
Case "Click to Minimize Form"
Me.Visible() = False
Case "Exit"
Me.Close()
End Select
End Sub
End Class
|