title: Windows.Forms: Activate an application that is already running in right FormWindowState
body: <p>Our application has the following requirement: If the application is running and I start the application again, the first instance has to be activated instead to open a new instance.</p>
  
  <p>To realize this, in the main routine I check if there is already a running instance. If yes I use following command to bring in front the first instance:</p>
  
  <pre><code>Microsoft.VisualBasic.Interaction.AppActivate(appIdentifier);
  </code></pre>
  
  <p>Until now all works as expected.
  The only problem with this solution is that in case of the first instance is minimized, by start the application again the first instance will be active, but not visible (still minimized)</p>
  
  <p>And this is my question. How can I go back to the last WindowState by activating the instance.
  My solution was, to subscribe for the Form.Activated event and execute following code in the eventhandler method:</p>
  
  <pre><code>if (MyForm.WindowState == FormWindowState.Minimized)
       {
          MyForm.WindowState = FormWindowState.Normal;
       }
  </code></pre>
  
  <p>But with this solution I have the problem, that if the application was in maximized-state before minimizing the application do not goes back to it after activate it.</p>
  
  <p>Has anybody an idea how I can solve this? is there a chance to get the last windowState?</p>
  
  <p>Thanks in advance for your help!</p>