2010-11-22 54 views
0

有没有人知道为什么当我运行该程序,并去点击任务栏项目打开小文本输入区域,图标就消失了,只要我到达它! !当我将鼠标悬停在它上面时,C#TaskBar项目消失

非常感谢

using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Linq; 
using System.Text; 
using System.Windows.Forms; 

namespace systemTray 
{ 
    public partial class Form1 : Form 
    { 
     public Form1() 
     { 
      InitializeComponent(); 
     } 

     private void button1_Click(object sender, EventArgs e) 
     { 
     } 

     private void Form1_Load(object sender, EventArgs e) 
     { 
      this.Visible = false; 
     } 

     private void Form1_Resize(object sender, System.EventArgs e) 
     { 
      if (FormWindowState.Minimized == WindowState) 
      { 
       Hide(); 
      } 
     } 

     private void notifyIcon1_DoubleClick(object sender, System.EventArgs e) 
     { 
      var screen = Screen.PrimaryScreen; 
      this.Left = screen.WorkingArea.Right - this.Width; 
      this.Top = screen.WorkingArea.Bottom - this.Height; 

      Application.Run(); 
     } 

     private void searchToolStripMenuItem_Click(object sender, EventArgs e) 
     { 
     } 

     private void quitToolStripMenuItem_Click(object sender, EventArgs e) 
     { 
      Close(); 
     } 
    } 
} 

编辑:我不知道这是否帮助,但使应用程序无法打开我改变的主要方法从

Application.run(new form1()) 

new form1() 
形式

回答

1

Application.Run是用来运行你的Windows窗体应用程序,

static void Main() 
{ 
    Application.EnableVisualStyles(); 
    Application.SetCompatibleTextRenderingDefault(false); 
    Application.Run(new Form1()); 
} 

当你删除的行Application.Run(new Form1());那么你的应用刚刚起步,并呼吁Main()之后,它被关闭,因为它已经完成它的工作。

问题是为什么你删除Application.Run(new Form1());

+0

因为这个http://stackoverflow.com/questions/70272/single-form-hide-on-startup – tom 2010-11-22 12:07:45

相关问题