winform图标最小化显示在任务栏右下角

http://www.cnblogs.com/shenyixin/archive/2013/07/05/3173640.html

private void Form1_SizeChanged(object sender, EventArgs e)
{
    if (this.WindowState == System.Windows.Forms.FormWindowState.Minimized)
    {
        this.Hide();
        this.notifyIcon1.Visible = true;
    }
    if (this.WindowState == FormWindowState.Normal)
    {
        this.notifyIcon1.Visible = false;
    }
}
 
private void Form1_FormClosing(object sender, FormClosingEventArgs e)      
  {           
     if (e.CloseReason == CloseReason.UserClosing)//当用户点击窗体右上角X按钮或(Alt + F4)时 发生           
     {                
         e.Cancel = true;                
         this.ShowInTaskbar = false;               
         this.myIcon.Icon = this.Icon;                
         this.Hide();           
     }        
  }               
  
  private void myIcon_MouseClick(object sender, MouseEventArgs e)        
  {           
   if (e.Button == MouseButtons.Right)            
   {                
       myMenu.Show();            
   }            
   
   if (e.Button == MouseButtons.Left)           
    {                
    this.Visible = true;                
    this.WindowState = FormWindowState.Normal;                            
    }        
 }                 
 
 private void toolMenuCancel_Click(object sender, EventArgs e)         
 {             
    Application.Exit();         
 }

winform图标最小化显示在任务栏右下角

上一篇:PHP官方Windows扩展列表


下一篇:Win7/Win10双系统安装方法图文教程