GetWindowRect检测bsSingle BoarderStyle

时间:2014-08-09 15:05:50

标签: delphi

对于这种寄宿生风格,我使用GetWindowRect:

enter image description here

我想总是获得完整窗口的坐标。谢谢你的帮助

1 个答案:

答案 0 :(得分:1)

这有效:

uses
  Winapi.DwmApi;

procedure TForm1.Button1Click(Sender: TObject);
var
  R: TRect;
begin
  if (Win32MajorVersion >= 6) and DwmCompositionEnabled then
    DwmGetWindowAttribute(Handle, DWMWA_EXTENDED_FRAME_BOUNDS, @R, SizeOf(R))
  else
    Windows.GetWindowRect(Handle, R);
  ShowMessage(IntToStr(R.Right - R.Left))
end;