title: Hidden WinForms modal dialogs
body: <p>I have a WinForms app (.NET 4) that has a main form and two modal dialogs as follows:</p>
  
  <ul>
  <li>FormMain: Run via <code>Application.Run(new FormMain())</code>.</li>
  <li>FormSettings: Launched from <code>FormMain:</code> <code>new FormSettings().ShowDialog(this)</code>.</li>
  <li>FormCredentials: Launched from <code>FormSettings:</code> <code>new FormCredentials().ShowDialog(this)</code>.</li>
  </ul>
  
  <p>When all three forms have normal borders and sizing, everything works fine. However, this app is supposed to appear in full screen and I use the following code only on <code>FormMain</code> to achieve that:</p>
  
  <pre><code>        FormMain.FormBorderStyle = FormBorderStyle.FixedSingle;
          FormMain.MinimizeBox = false;
          FormMain.MaximizeBox = false;
  
          FormMain.Text = "";
          FormMain.ControlBox = false;
          FormMain.ShowInTaskbar = false;
          FormMain.TopMost = !Configuration.Debug;
          FormMain.TopLevel = true;
  </code></pre>
  
  <p>The other two dialogs have their <code>FormBorderStyle = FormBorderStyle.FixedSingle</code>.</p>
  
  <p>So <code>FormMain</code> launches <code>FormSettings</code> as a modal dialog and <code>FormSettings</code> launches <code>FormCredentials</code> as a modal dialog. <code>FormCredentials</code> ALWAYS disappears behind <code>FormMain</code>. In fact any third-level form disappears behind <code>FormMain</code>.</p>
  
  <p>Searching for this behaviour brought up suggestions for specifying the form owner which I'm already doing in the call to <code>ShowDialog(this)</code>.</p>
  
  <p>Any other reasons for it to behave this way?</p>
  
  <p><strong>EDIT:</strong> This only happens in release mode so the the line <code>FormMain.TopMost = !Configuration.Debug</code> may have something to do with it. That line ensures the end-user cannot get out of the app when it is running as a kiosk.</p>