2010-11-22 12 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(); 
     } 
    } 
} 

編集:私は、このアプリケーションは、私が

new form1() 

Application.run(new form1()) 

からmainメソッドを変更し、フォームを開けないで作ることではなく場合に役立ちますわかりません

答えて

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

関連する問題