2010-11-22 57 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

相關問題