Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6163761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:52:46+00:00 2026-05-23T21:52:46+00:00

The Delphi application checks if a form instance is already open this way: form

  • 0

The Delphi application checks if a form instance is already open this way:

  form := FindWindow(PAnsiChar(FormClassName), nil);
  if form > 0 then
  begin
    SendMessage(form, WM_ACTIVATEAPP, 0, 0);
    Result := True;
  end else
    Result := False

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:-(

How do I make this function return false if the form class instance is created in the Designer?


Answer:

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 :

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 > 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;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T21:52:46+00:00Added an answer on May 23, 2026 at 9:52 pm

    Use Getwindowthreadprocessid to get the process id of the window if that Id equals your process that means that is a valid window.sorry i can’t post an example but i am writing from my mobile

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Delphi application that has a document browser as the main form.
What is the best way to make a Delphi application (Delphi 2007 for Win32)
We have an application server developed with Delphi 2010 and Indy 10. This server
I am porting a Delphi application to FPC/Lazarus and this application shows info in
I have a Delphi application similar to Taskbar Shuffle that includes a hook dll.
I am porting a Delphi application to C# and I've run into a problem.
I need to write a Delphi application that pulls entries up from various tables
I would like to create a Delphi application for Windows XP which allows dropping
Which component is best to use for receiving HTTP requests in Delphi application?
I'm using the TServerSocket component in my Delphi application. I would like to limit

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.