C#实现系统托盘通知的方法

本文实例讲述了C#实现系统托盘通知的方法。分享给大家供大家参考。具体实现方法如下:

namespace WindowsApplication1
{
  public partial class Form1 : Form
  {
    public Form1()
    {
      InitializeComponent();
    }
    private void timer1_Tick(object sender, EventArgs e)
    {
      this.Activate();
    }
    private void Form1_Resize(object sender, EventArgs e)
    {
      if (FormWindowState.Minimized == WindowState)
      {
        this.notifyIcon1.Visible = true;
        this.Visible = false;
      }
    }
    private void openToolStripMenuItem_Click(object sender, EventArgs e)
    {
      this.notifyIcon1.Visible = false;
      this.Show();
      WindowState = FormWindowState.Normal;
    }
    private void closeToolStripMenuItem_Click(object sender, EventArgs e)
    {
      this.Close();
    }
    private void Form1_Load(object sender, EventArgs e)
    {
    }
  }
}

希望本文所述对大家的C#程序设计有所帮助。

你可能感兴趣的:(C#实现系统托盘通知的方法)