tags:

views:

71

answers:

3

How can I create a program that runs in the background, and can be accessed via the Windows' "Notification Area" (Where the date and time are in the lower right hand corner)?

In other words, I want to be able to create a program that runs and can toggle between having a display window and not having a display window.

A: 

See this link: Traybar app

mdm20
+2  A: 
  1. Drag and drop a NotifyIcon and a ContextMenuStrip.
  2. Set de NotifyIcon's context menu to the one you added
  3. Add 2 menuitems (e.g. Restore, Exit)
  4. Set the Form event resize and do the following check

    private void MyForm_Resize(object sender, EventArgs e)
    {
        if (this.WindowState == FormWindowState.Minimized) this.Hide();
        else this.Show();
    }
    
    
    // you could also restore the window with a
    // double click on the notify icon
    private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
    {
        this.Show();
        this.WindowState = FormWindowState.Normal;
    }
    

For a example can download this project

Don't worry about the right click event, the NotifyIcon will automatically detect it and show the ContextMenu

BrunoLM