title: How to check if opened form instance is from designer?
body: <p>The Delphi application checks if a form instance is already open this way:</p>
  
  <pre><code>  form := FindWindow(PAnsiChar(FormClassName), nil);
    if form &gt; 0 then
    begin
      SendMessage(form, WM_ACTIVATEAPP, 0, 0);
      Result := True;
    end else
      Result := False
  </code></pre>
  
  <p>The problem is that when the form is open as a Delphi Designer windows it says that the form is open. I've just lost some working hours because when I opened a form and clicked to breakpoint a method, the application stopped to work:-( </p>
  
  <p>How do I make this function return false if the form class instance is created in the Designer?</p>
  
  <hr>
  
  <p><strong>Answer:</strong><Br>
  opc0de's suggestion below leaded me to a good solution, so I'm accepting his comment as the answer. I needed to change the code to iterate through all open forms. Here is the final version of the code for the happiness of the copy'n pasters of the world :</p>
  
  <pre><code>function VerifyFormIsOpen(formClass: String): Boolean;
  var
    windowHndl, windowOld: HWND;
    processId: Cardinal;
  begin
    windowOld := 0;
    windowHndl := 0;
    Result := False;
    repeat
      windowHndl :=  Windows.FindWindowEx(0, windowOld,
                                      PAnsiChar(formClass), nil);
      if (windowHndl &gt; 0) then
      begin
        Windows.GetWindowThreadProcessId(windowHndl, processId);
        if processId = Windows.GetCurrentProcessId() then
        begin
          Windows.SendMessage(windowHndl, Messages.WM_ACTIVATEAPP, 0, 0);
          Result := True;
          break;
        end;
      end;
      windowOld := windowHndl;
    until windowHndl = 0;
  end;
  </code></pre>