delphi - 如何获取 Delphi IDE 的主窗体?

标签 delphi ide

我正在为 Delphi 编写一个属性编辑器,我希望它能够显示在正确的屏幕上以支持多显示器。为了定位它,我想要一个对 Delphi IDE 的“主”表单的引用。

我尝试过使用应用程序的 MainForm 属性和应用程序对象本身,但似乎都不起作用。我相信这是因为 MainForm 实际上是 Nathanial Woolls 在本文中引用的隐藏 TApplication 实例(搜索“申请表”):

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

有谁知道如何获取 IDE 可见主窗体的句柄。我试图避免一些俗气的事情,比如迭代所有表单并在标题中搜索“CodeGear RAD Studio”。

最佳答案

IDE 的主窗体是Application.MainForm。我的快速测试设计包:

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);

在我的例子中,这显示“AppBuilder [TAppBuilder] 在监视器 0 上”,并且我可以在主窗体的标题中看到“- this one”后缀。 在您的情况下,什么似乎不起作用?

关于delphi - 如何获取 Delphi IDE 的主窗体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/967327/

相关文章:

delphi - 如何将 vcl 样式 Hook 应用于表单的特定组件?

delphi - 使用 Delphi 检测 Windows 中何时安装卷

delphi - 哪些列表可以作为临时列表?

c# - Visual Studio 2012 和 MVC 4 : How to deploy individual files/folders to filesystem?

delphi - 由于事件处理中的周期,Delphi堆栈溢出

eclipse - 使用 Eclipse CDT 和 GDB 进行调试 : can't find source file

emacs - CLISP 程序员使用哪个 IDE?

c++ - 使Eclipse生成C++可执行文件

vb6 - 更改 'References' 对话框宽度?

delphi - 在 Delphi 中进行非闪烁、分段图形更新的最佳方法?