title: How to start WinForm app minimized to tray?
body: <p>I've successfully created an app that minimizes to the tray using a NotifyIcon. When the form is manually closed it is successfully hidden from the desktop, taskbar, and alt-tab. The problem occurs when trying to start with the app minimized. At first the problem was that the app would be minimized but would still appear in the alt-tab dialog. Changing the FormBorderStyle to one of the ToolWindow options (from the "None" option) fixed this, but introduced another problem. When the app first starts the titlebar of the minimized window is visible just above the start menu:</p>
  
  <p><a href="https://i.stack.imgur.com/FwfAW.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/FwfAW.gif" alt="enter image description here"></a></p>
  
  <p>Opening the form and the closing it causes it to hide properly. I've tried lots of variations, but here's essentially how it's working right now...</p>
  
  <p>WindowState is set to Minimized in the Designer. After some initialization in the constructor I have the following lines:</p>
  
  <pre><code>this.Visible = false;
  this.ShowInTaskbar = false;
  </code></pre>
  
  <p>When the NotifyIcon is double-clicked I have the following:</p>
  
  <pre><code> this.WindowState = FormWindowState.Normal;
   this.Visible = true;
   this.ShowInTaskbar = true;
  </code></pre>
  
  <p>Like I said, I've tried lots of minor variations on this (this.Hide(), etc.). Is there a way to have the NotifyIcon be the primary component such that I can completely start and dispose of the form while leaving the NotifyIcon running? There's got to be a way to start the app with the form minimized without any of the weirdness. Please help me find it!</p>