How can I get the main form of the Delphi IDE?

I am writing a property editor for Delphi, and I would like it to appear on the right screen to support multiple monitors. To post it, I need a link to the "main" form for the Delphi environment.

I tried using the MainForm property of the application and the application object itself, but none of them work. I believe this is because MainForm is actually a hidden TApplication instance specified in this Nathanial Woolls article (search for "application form"):

http://www.installationexcellence.com/articles/VistaWithDelphi/Original/Index.html

Does anyone know how to get the handle of the visible main form for the IDE. I try to avoid something trashy, like repeating all forms and searching for "CodeGear RAD Studio" in the title.

+3
source share
2 answers

The main form of the IDE is Application.MainForm. My package for quick testing:

procedure DoStuff(Form: TCustomForm);
var
  S: string;
begin
  S := Form.Caption;
  Form.Caption := S + ' - this one';
  try
    ShowMessage(Format('%s [%s] on monitor %d', [Form.Name, Form.ClassName, Form.Monitor.MonitorNum]));
  finally
    Form.Caption := S;
  end;
end;

initialization
  DoStuff(Application.MainForm);

In my case, “AppBuilder [TAppBuilder] is displayed on monitor 0”, and I can see the suffix “- this” in the main form caption. What does not seem to work in your case?

+4
source

IIRC is the main form called TAppBuilder, so something like FindWindow('TAppBuilder',nil)may be the starting point for you.

+2
source

Source: https://habr.com/ru/post/1710034/


All Articles