Here's my sub for creating a new tray icon with a context menu! Many thanks to you guys for helping out.
VB Code:
Sub CreateTrayIcon() 'creates a new tray icon Dim TrayIcon As New System.Windows.Forms.NotifyIcon 'creates a new icon Dim Icon As New System.Drawing.Icon("C:\icon.ico") 'assigns the icon to the tray icon TrayIcon.Icon = Icon 'makes the trayicon visible TrayIcon.Visible = True 'Sets the text on the menu item mnuQuit.Text = "Quit" 'Creates a new context menu Dim TrayIconContextMenu As New System.Windows.Forms.ContextMenu 'Adds items to the new context menu TrayIconContextMenu.MenuItems.Add(mnuQuit) 'Assigns the created contextmenu to the trayicon TrayIcon.ContextMenu = TrayIconContextMenu End Sub
Now I'm left with one last problem. My context menu is totally unresponsive to being clicked when the program is running. I've tried putting it in a thread, but that was just pointless as the icon disappears when the thread stops running.




Reply With Quote