winform如何最小化成托盘图标

mac2022-06-30  77

 

     public   partial   class  MainForm : Form     {         FormWindowState fws  =  FormWindowState.Normal;          public  MainForm()         {             InitializeComponent();              this .SizeChanged  +=   new  EventHandler(MainForm_SizeChanged);              this .notifyIcon1.DoubleClick  +=   new  EventHandler(notifyIcon1_DoubleClick);              this .notifyIcon1.Icon  =   new  Icon( " Virgo.ico " );              this .notifyIcon1.Visible  =   false ;         }          void  MainForm_SizeChanged( object  sender, EventArgs e)         {              if  ( this .WindowState  ==  FormWindowState.Minimized)             {                  this .ShowInTaskbar  =   false ;                  this .notifyIcon1.Visible  =   true ;             }              else             {                 fws  =   this .WindowState;             }         }          void  notifyIcon1_DoubleClick( object  sender, EventArgs e)         {              if  ( this .WindowState  ==  FormWindowState.Minimized)             {                  this .ShowInTaskbar  =   true ;                  this .notifyIcon1.Visible  =   false ;                  this .WindowState  =  fws;             }         }     }

转载于:https://www.cnblogs.com/KenBlove/archive/2008/09/02/1281890.html

最新回复(0)