| | 2017/3/23 (木) 14:29:58  Mr.XRAY | 
 | [Windows10でフォームのサイズ、位置が思い通りにならない]http://madia.world.coocan.jp/cgi-bin/DelphiBBS/wwwlng.cgi?print+201703/17030007.txt
 
 マイクロソフトの仕様ですね (笑)
 EXE を Windows 7 U64(SP1) + Delphi XE(UP1) Pro で作成してテストした結果です.
 Form1 の BorderStyle は bsSizeable でテストしています.
 
 Windows 10 の場合,フォームの幅ではなく,ウインドウの幅でキャフチャしないと,
 周辺に背景が入ったキャプチャ画像となるわけです.
 
 
 uses
 DWMAPI;
 
 {$R *.dfm}
 
 function GetWindowRectForVista(hWindow: HWND): TRect;
 var
 ARect : TRect;
 begin
 //Windows Vista以降は拡張フレーム
 if CheckWin32Version(6, 0) then begin
 //拡張したウィンドウのフレームのTRect構造体の値を取得
 DwmGetWindowAttribute(hWindow,
 DWMWA_EXTENDED_FRAME_BOUNDS,
 @ARect,
 SizeOf(TRect));
 end else begin
 GetWindowRect(hWindow, ARect);
 end;
 Result := ARect;
 end;
 
 procedure TForm1.Button1Click(Sender: TObject);
 var
 LVersion  : string;
 LRect     : TRect;
 LWidth1   : Integer;
 LWidth2   : Integer;
 LText     : string;
 begin
 Self.Width := Screen.Width;
 Self.Left := 0;
 
 if CheckWin32Version(10, 0) then begin
 LVersion := 'Windows 10';
 end else
 if CheckWin32Version(6, 3) then begin
 LVersion := 'Windows 8.1';
 end else
 if CheckWin32Version(6, 2) then begin
 LVersion := 'Widows 8';
 end else
 if CheckWin32Version(6, 1) then begin
 LVersion := 'Widows 7';
 end;
 
 GetWindowRect(Handle, LRect);
 LWidth1 := LRect.Right - LRect.Left;
 
 LRect := GetWindowRectForVista(Handle);
 LWidth2 := LRect.Right - LRect.Left;
 
 LText := LVersion + sLineBreak
 + 'Screen.width : ' + IntToStr(Screen.Width) + sLineBreak
 + 'TForm.Left : ' + IntToStr(Self.Left) + sLineBreak
 + 'TForm.width : ' + IntTostr(Self.Width) + sLineBreak
 + 'GetWindowRect : ' + IntTostr(LWidth1) + sLineBreak
 + 'Windows.width : ' + IntToStr(LWidth2);
 MessageBox(Handle, PChar(LText), 'フォームの幅', MB_ICONINFORMATION);
 end;
 
 
 
 
  | 
 |