Close form to system tray


April 11, 2009
Don't know what to read next? Check out the list of popular posts. People like them, they should be good.

another tip »

Instead of close down the app, the app hide in the system tray instead.
Will require a NotifyIcon and a ContextToolStrip

public bool ExitTime = false;

        private void FrmMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (!ExitTime)
            {
                e.Cancel = true;
                this.Hide();
            }
        }

        private void ntIcon_DoubleClick(object sender, EventArgs e)
        {
            this.Show();
        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ExitTime = true;
            Application.Exit();
        }
  • Delicious

Some more useful articles for you

Under Category: C#.NET Code
Article Tags: , ,
October 22nd, 2009

Isn’t that like all the content worth crawling? ,

Trackbacks
Leave a Reply