C# 在托盘显示图标

//上面一行是主窗体InitializeComponent()方法中需要添加的引用

this.SizeChanged += new System.EventHandler(this.Form1_SizeChanged);

 1 //上面一行是主窗体InitializeComponent()方法中需要添加的引用 
 2         private void Form1_SizeChanged(object sender, EventArgs e)
 3         {
 4             if (this.WindowState == FormWindowState.Minimized)
 5             {
 6                 this.Hide();
 7                 this.notifyIcon1.Visible = true;
 8             }
 9         }
10 
11         private void notifyIcon1_Click(object sender, EventArgs e)
12         {
13             this.Visible = true;
14             this.WindowState = FormWindowState.Normal;
15             this.notifyIcon1.Visible = false;
16             this.Activate();
17             this.ShowInTaskbar = true;//任务栏区显示图标
18         }

 

posted @ 2013-10-08 20:03  宁静.致远  阅读(696)  评论(0编辑  收藏  举报