如何获得Delphi IDE的主窗体? [英] How can I get the Delphi IDE's Main Form?
问题描述
我正在为Delphi编写属性编辑器,我希望它显示在正确的屏幕上以支持多显示器。为了定位它,我想引用Delphi IDE的主表单。
I'm writing a property editor for Delphi and I would like it to show up on the correct screen for multi-monitor support. In order to position it, I would like a reference to the "main" form for the Delphi IDE.
我尝试使用Application的MainForm属性和应用程序对象本身,但似乎都不起作用。我相信这是因为MainForm实际上是Nathanial Woolls在本文中引用的隐藏的TApplication实例(搜索申请表):
I've tried using the Application's MainForm property, and the Application object itself, but neither seems to work. I believe this is because the MainForm is actually the hidden TApplication instance referenced in this article by Nathanial Woolls (search for "application form"):
http://www.installationexcellence.com/articles/VistaWithDelphi/Original/Index.html
有没有人知道如何获取IDE的可见主窗体的句柄。我试图避免一些俗气,比如迭代所有表格并在标题中搜索CodeGear RAD Studio。
Does anyone know how to get a handle to the visible main form for the IDE. I'm trying to avoid something cheesy like iterating all forms and searching for "CodeGear RAD Studio" in the caption.
推荐答案
IDE的主要形式是Application.MainForm。我的快速测试设计包:
The IDE's main form is Application.MainForm. My quick test design package:
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);
这在我的案例中显示监视器0上的AppBuilder [TAppBuilder],我可以看到 - 这一个主要形式的标题后缀。
你的情况似乎不起作用?
This in my case displays "AppBuilder [TAppBuilder] on monitor 0" and I can see the " - this one" suffix in the main form's caption. What doesn't seem to work in your case?
这篇关于如何获得Delphi IDE的主窗体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!