码迷,mamicode.com
首页 > Windows程序 > 详细

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

时间:2015-01-29 10:20:47      阅读:202      评论:0      收藏:0      [点我收藏+]

标签:

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图标最小化显示在任务栏右下角

标签:

原文地址:http://www.cnblogs.com/csharphuang/p/4258946.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!