简体   繁体   English

我如何知道Delphi IDE对象检查器在哪个监视器上?

[英]How can I tell what monitor the Delphi IDE Object Inspector is on?

This is a follow up to How can I get the Delphi IDE's Main Form? 这是我如何获得Delphi IDE的主表单的后续操作 which I now have working. 我现在正在工作。

I'd like to go one step further and place my designer on the same form as the Object Inspector, for those who use the classic undocked desktop layout and may have the Object Inspector on a different screen than the main Delphi IDE form. 对于想使用经典非停靠桌面布局并且可能将Object Inspector放在与主要Delphi IDE窗体不同的屏幕上的用户,我想更进一步,将我的设计器与Object Inspector放在同一表单上。

Any ideas on how I find which monitor the Object Inspector is on from inside my design time package? 关于在设计时程序包中如何找到对象检查器位于哪个监视器的任何想法?

This should work whether the property inspector is docked or not, since it falls back to the main form for the docked case: 无论属性检查器是否对接,这都应该起作用,因为它会退回到对接案例的主要形式:

function EnumWindowsProc(hwnd: HWND; lParam: LPARAM): Integer; stdcall;
var
  ClassName: string;
  PID: Cardinal;
begin
  Result := 1;
  GetWindowThreadProcessId(hwnd, PID);
  if PID = GetCurrentProcessId then 
  begin
    SetLength(ClassName, 64);
    SetLength(ClassName, GetClassName(hwnd, PChar(ClassName), Length(ClassName)));
    if ClassName = 'TPropertyInspector' then 
    begin
      PHandle(lParam)^ := hwnd;
      Result := 0;
    end;
  end;
end;

function GetPropertyInspectorMonitor: TMonitor;
var
  hPropInsp: HWND;
begin
  hPropInsp := 0;
  EnumWindows(@EnumWindowsProc, LPARAM(@hPropInsp));
  if hPropInsp = 0 then
    hPropInsp := Application.MainFormHandle;
  Result := Screen.MonitorFromWindow(hPropInsp);
end;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM