Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
ok heres the deal: i wanna make an app that is just a system tray icon that i can right click and do stuff. i am trying not to involve a form at all. i just want to be able to right clikc the icon and bring up a menu and then select something from the menu for the program to do. wut im trying to say may be confusing but just ask me and ill go into more detail.
  • *Experts*
Posted

To get the icon into the system tray use the System.Windows.Form.NotifyIcon class. Then you have to add a context menu object to the icon, using the ContextMenu property orf the icon.

Dim mnu As New ContextMenu
mnu.MenuItems.Add("Hello") 'there is also an overload that accepts an event handler so you can use that
trayicon.ContextMenu = mnu

You also will have to set an icon image for the icon.

trayicon.Icon = new Icon("path")

Also, you have to make it visible.

trayicon.Visible = True

Now, to make that happen, you can start your program from sub Main. Forst declare the tray icon and the menu, then use the Application.Run() method to start the message loop for your app.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...