2011-04-12 14 views
2

notifyIconをコンテナに追加し、Visible = trueオプションを設定しましたが、アイコンは表示されませんでした。フォームなしでnotifyIconを作成するには?

private void InitializeComponent() 
     { 
      this.components = new System.ComponentModel.Container(); 
      this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components); 
      this.SuspendLayout(); 
      // 
      // notifyIcon1 
      // 
      this.notifyIcon1.Text = "Manager"; 
      this.notifyIcon1.Visible = true; 
      // 
      // Form1 
      // 
      this.ClientSize = new System.Drawing.Size(0, 0); 
      this.ShowInTaskbar = false; 
      this.Visible = false; 

     } 

答えて

2

が、希望はこれが

public Form2() 
    { 
     InitializeComponent(); 
     notifyIcon1.Icon = SystemIcons.Asterisk; 
     notifyIcon1.DoubleClick += new EventHandler(notifyIcon1_DoubleClick);// to bring it back 
     this.Resize += new EventHandler(Form2_Resize);// to move it to tray 
    } 

    void notifyIcon1_DoubleClick(object sender, EventArgs e) 
    { 
     Show(); 
     this.BringToFront(); 
     this.WindowState = FormWindowState.Normal; 
    } 

    void Form2_Resize(object sender, EventArgs e) 
    { 
     if (this.WindowState ==FormWindowState.Minimized) 
      Hide(); 
    } 
+1

ありがとうございます。必要なのはnotifyIcon1.Icon = SystemIcons.Asterisk; – BILL

0

通知フォームが最小化されているときにアイコンが表示されます。私はあなたがこれが動作するために、いくつかのより多くのイベントを追加する必要があると信じて、この

this.WindowState = FormWindowState.Minimized; 
+0

影響なしに役立ちます試してみてください。アイコンが表示されません。 – BILL

関連する問題