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         }

 

你可能感兴趣的:(C#)