mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-28 21:00:43 +02:00
win32: high-dpi fixes for multi-resolution (multi-monitor) setup (2)
This commit is contained in:
parent
529c0bff68
commit
30789b5c94
@ -2406,13 +2406,8 @@ end;
|
||||
------------------------------------------------------------------------------}
|
||||
function TWin32WidgetSet.GetWindowSize(Handle : hwnd;
|
||||
var Width, Height: integer): boolean;
|
||||
var
|
||||
WP: WINDOWPLACEMENT;
|
||||
R: TRect;
|
||||
WindowInfo: PWin32WindowInfo;
|
||||
Info: tagWINDOWINFO;
|
||||
|
||||
procedure AdjustUpDownSize;
|
||||
procedure AdjustUpDownSize(WindowInfo: PWin32WindowInfo; WP: WINDOWPLACEMENT);
|
||||
var
|
||||
UpDownWP: WINDOWPLACEMENT;
|
||||
begin
|
||||
@ -2421,13 +2416,28 @@ var
|
||||
Width := Max(Width, UpDownWP.rcNormalPosition.Right - WP.rcNormalPosition.Left);
|
||||
end;
|
||||
|
||||
procedure ExcludeCaption; inline;
|
||||
procedure ExcludeBorder(dwStyle, dwExStyle: DWORD);
|
||||
begin
|
||||
if (Info.dwStyle and (WS_CHILD or WS_CAPTION)) = WS_CAPTION then
|
||||
if (Info.dwExStyle and WS_EX_TOOLWINDOW) <> 0 then
|
||||
{$IFNDEF LCLRealFormBounds}
|
||||
if (dwStyle and WS_THICKFRAME) = WS_THICKFRAME then
|
||||
Dec(Width, 2*(GetSystemMetricsForDpi(SM_CXSIZEFRAME, GetDpiForWindow(Handle))+GetSystemMetricsForDpi(SM_CXPADDEDBORDER, GetDpiForWindow(Handle))))
|
||||
else
|
||||
if (dwStyle and WS_BORDER) = WS_BORDER then
|
||||
Dec(Width, 2*(GetSystemMetricsForDpi(SM_CXFIXEDFRAME, GetDpiForWindow(Handle))));
|
||||
if (dwStyle and WS_THICKFRAME) = WS_THICKFRAME then
|
||||
Dec(Height, 2*(GetSystemMetricsForDpi(SM_CYSIZEFRAME, GetDpiForWindow(Handle))+GetSystemMetricsForDpi(SM_CXPADDEDBORDER, GetDpiForWindow(Handle))))
|
||||
else
|
||||
if (dwStyle and WS_BORDER) = WS_BORDER then
|
||||
Dec(Height, 2*(GetSystemMetricsForDpi(SM_CYFIXEDFRAME, GetDpiForWindow(Handle))));
|
||||
|
||||
if (dwStyle and (WS_CHILD or WS_CAPTION)) = WS_CAPTION then
|
||||
begin
|
||||
if (dwExStyle and WS_EX_TOOLWINDOW) <> 0 then
|
||||
Dec(Height, GetSystemMetricsForDpi(SM_CYSMCAPTION, GetDpiForWindow(Handle)))
|
||||
else
|
||||
Dec(Height, GetSystemMetricsForDpi(SM_CYCAPTION, GetDpiForWindow(Handle)));
|
||||
end;
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
procedure SetWidthHeightFromRect(const R: TRect); inline;
|
||||
@ -2436,6 +2446,11 @@ var
|
||||
Height := R.Bottom - R.Top;
|
||||
end;
|
||||
|
||||
var
|
||||
WP: WINDOWPLACEMENT;
|
||||
R: TRect;
|
||||
Info: tagWINDOWINFO;
|
||||
WindowInfo: PWin32WindowInfo;
|
||||
begin
|
||||
WP.length := SizeOf(WP);
|
||||
Result := Boolean(Windows.GetWindowPlacement(Handle, WP));
|
||||
@ -2457,13 +2472,7 @@ begin
|
||||
SetWidthHeightFromRect(WP.rcNormalPosition)
|
||||
else
|
||||
SetWidthHeightFromRect(Info.rcWindow);
|
||||
{$IFNDEF LCLRealFormBounds}
|
||||
if Info.cxWindowBorders>0 then
|
||||
Dec(Width, 2*(GetSystemMetricsForDpi(SM_CXSIZEFRAME, GetDpiForWindow(Handle))+GetSystemMetricsForDpi(SM_CXPADDEDBORDER, GetDpiForWindow(Handle))));
|
||||
if Info.cyWindowBorders>0 then
|
||||
Dec(Height, 2*(GetSystemMetricsForDpi(SM_CYSIZEFRAME, GetDpiForWindow(Handle))+GetSystemMetricsForDpi(SM_CXPADDEDBORDER, GetDpiForWindow(Handle))));
|
||||
ExcludeCaption;
|
||||
{$ENDIF}
|
||||
ExcludeBorder(Info.dwStyle, Info.dwExStyle);
|
||||
//WriteLn('W = ', Width, ' H = ', Height);
|
||||
Exit;
|
||||
end;
|
||||
@ -2484,9 +2493,14 @@ begin
|
||||
SetWidthHeightFromRect(WP.rcNormalPosition);
|
||||
end;
|
||||
|
||||
{$IFNDEF LCLRealFormBounds}
|
||||
// convert top level lcl window coordinaties to win32 coord
|
||||
ExcludeBorder(DWORD(GetWindowLong(Handle, GWL_STYLE)), DWORD(GetWindowLong(Handle, GWL_EXSTYLE)));
|
||||
{$ENDIF}
|
||||
|
||||
WindowInfo := GetWin32WindowInfo(Handle);
|
||||
if WindowInfo^.UpDown <> 0 then
|
||||
AdjustUpDownSize;
|
||||
AdjustUpDownSize(WindowInfo, WP);
|
||||
end;
|
||||
|
||||
function TWin32WidgetSet.GradientFill(DC: HDC; Vertices: PTriVertex;
|
||||
|
Loading…
Reference in New Issue
Block a user