如何判断Delphi IDE Object Inspector的监视器是什么?

Jer*_*lin 2 ide delphi

这是对如何获得Delphi IDE主表单的跟进我现在有工作.

我想更进一步,将我的设计师放在与Object Inspector相同的表格上,对于那些使用经典的未对接桌面布局并且可能在与主Delphi IDE表单不同的屏幕上使用Object Inspector的人.

关于如何在设计时包中找到Object Inspector的监视器的任何想法?

Zoë*_*son 5

无论属性检查器是否已停靠,这都应该有效,因为它会回退到停靠案例的主要表单:

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;
Run Code Online (Sandbox Code Playgroud)

  • 您也可以使用Delphi方式,例如枚举Screen.Forms并检查ClassNameIs('TPropertyInspector')或使用Application.FindComponent('PropertyInspector'). (2认同)