写小程序遇到的问题

来源:互联网 发布:淘宝可以申请几次售后 编辑:程序博客网 时间:2024/05/16 23:59

1.窗体最小化到任务栏处,主要实现代码如下:

his.Deactivate+=new EventHandler(Form1_Mini);

private void Form1_Mini(object sender, System.EventArgs e)
{
        if(this.WindowState==FormWindowState.Minimized)
 {
  this.Visible=false;      
  this.notifyIcon1.Visible=true;
 }
}

private void notifyIcon1_Click(object sender, System.EventArgs e)
{
 this.Visible=true;  
 this.WindowState=FormWindowState.Normal;
 this.Activate();  
 this.notifyIcon1.Visible=false;
}

2.调用一个窗体,隐藏本窗体


在一个窗体调用另一个窗口:
第一个窗体:frmMain,第二个窗体:frmShow
frmShow:
public static System.Windows .Forms.Form vform=null;
frmShow.vform.Visible =false;

frmMain:
在main函数中写:

frmShow.vform =new frmMain ();
Application.Run (frmShow.vform);

3.实现左右鼠标点击

private void notifyIcon1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
   
   //this.notifyIcon1.Visible=false;
 if (e.Button ==MouseButtons.Left )
 {
  this.Visible=true;  
  this.WindowState=FormWindowState.Normal;
  this.Activate();  
 }
 if (e.Button ==MouseButtons.Right )
 {
 }
  
}//鼠标的左右键!