title: Delphi: How to use ShowWindow properly on external application
body: <blockquote>
    <p><strong>See also:</strong><br>
    <a href="https://stackoverflow.com/questions/459554/how-can-i-tell-if-another-instance-of-my-program-is-already-running">How can I tell if another instance of my program is already running?</a>  </p>
  </blockquote>
  
  
  
  <p>i use the following code before starting my application, to check if another instance
  of it is already started:</p>
  
  <pre><code>var _PreviousHandle : THandle;
  begin
    _PreviousHandle := FindWindow('TfrmMainForm',nil);
    if _PreviousHandle &lt;&gt; 0 then
    begin
      ShowMessage('Application "" is already running!');
      SetForegroundWindow(_PreviousHandle);
      ShowWindow(_PreviousHandle, SW_SHOW);
      Application.Terminate;
      Exit;
    end;
  ...
  </code></pre>
  
  <p>However, if it has started, i need to show that application. The problem is after it is shown in this way the minimize button no longer works, and when i click the icon in the taskbar, it "unminimizes" and the animation that is shown is as if it was minimized. Am i missing something? is there a proper way to activate and show external application while it's minimized?</p>