As mat1t says - you need to add a NotifyIcon to your application and then use something like the following code to set the tooltip and context menu:
this.notifyIcon.Text = "This is the tooltip";
this.notifyIcon.ContextMenu = new ContextMenu();
this.notifyIcon.ContextMenu.MenuItems.Add(new MenuItem("Option 1", new EventHandler(handler_method)));
This code shows the icon in the system tray only:
this.notifyIcon.Visible = true; // Shows the notify icon in the system tray
The following will be needed if you have a form (for whatever reason):
this.ShowInTaskbar = false; // Removes the application from the taskbar
Hide();
The right click to get the context menu is handled automatically, but if you want to do some action on a left click you'll need to add a Click handler:
private void notifyIcon_Click(object sender, EventArgs e)
{
var eventArgs = e as MouseEventArgs;
switch (eventArgs.Button)
{
// Left click to reactivate
case MouseButtons.Left:
// Do your stuff
break;
}
}
icon.Visible = false
, thenDispose()
the icon when exiting your application. Otherwise you will still see the icon after your program exits. After testing it a couple of times, you'll no longer know, which icon is real. – Mischance