Fixed a size issue in SimpleFMXBrowser with a high DPI screen

This commit is contained in:
salvadordf 2021-12-03 18:34:44 +01:00
parent 25edba76e8
commit 3fef420fff
3 changed files with 19 additions and 6 deletions

View File

@ -78,6 +78,13 @@ object SimpleFMXBrowserFrm: TSimpleFMXBrowserFrm
Left = 40 Left = 40
Top = 192 Top = 192
end end
object BrowserLay: TLayout
Align = Client
Size.Width = 1000.000000000000000000
Size.Height = 565.000000000000000000
Size.PlatformDefault = False
TabOrder = 6
end
object FMXChromium1: TFMXChromium object FMXChromium1: TFMXChromium
OnBeforeContextMenu = FMXChromium1BeforeContextMenu OnBeforeContextMenu = FMXChromium1BeforeContextMenu
OnContextMenuCommand = FMXChromium1ContextMenuCommand OnContextMenuCommand = FMXChromium1ContextMenuCommand

View File

@ -66,6 +66,7 @@ type
Layout1: TLayout; Layout1: TLayout;
GoBtn: TButton; GoBtn: TButton;
SnapShotBtn: TButton; SnapShotBtn: TButton;
BrowserLay: TLayout;
procedure GoBtnClick(Sender: TObject); procedure GoBtnClick(Sender: TObject);
procedure Timer1Timer(Sender: TObject); procedure Timer1Timer(Sender: TObject);
@ -377,6 +378,7 @@ begin
begin begin
FClosing := True; FClosing := True;
Visible := False; Visible := False;
FMXChromium1.CloseBrowser(True); FMXChromium1.CloseBrowser(True);
end; end;
end; end;
@ -403,10 +405,10 @@ var
TempScale : single; TempScale : single;
begin begin
TempScale := FMXChromium1.ScreenScale; TempScale := FMXChromium1.ScreenScale;
Result.Left := 0; Result.Left := round(BrowserLay.Position.x);
Result.Top := round(AddressPnl.Height * TempScale); Result.Top := round(BrowserLay.Position.y);
Result.Right := round(ClientWidth * TempScale) - 1; Result.Right := Result.Left + round(BrowserLay.Width * TempScale);
Result.Bottom := round(ClientHeight * TempScale) - 1; Result.Bottom := Result.Top + round(BrowserLay.Height * TempScale);
end; end;
procedure TSimpleFMXBrowserFrm.ResizeChild; procedure TSimpleFMXBrowserFrm.ResizeChild;
@ -473,7 +475,9 @@ begin
TempRect.Bottom := round(TempClientRect.Bottom); TempRect.Bottom := round(TempClientRect.Bottom);
FMXChromium1.DefaultUrl := AddressEdt.Text; FMXChromium1.DefaultUrl := AddressEdt.Text;
if not(FMXChromium1.CreateBrowser(TempHandle, TempRect)) then Timer1.Enabled := True;
if not(FMXChromium1.CreateBrowser(TempHandle, TempRect)) then
Timer1.Enabled := True;
end; end;
end; end;
@ -487,7 +491,9 @@ var
PositionChanged: Boolean; PositionChanged: Boolean;
begin begin
PositionChanged := (ALeft <> Left) or (ATop <> Top); PositionChanged := (ALeft <> Left) or (ATop <> Top);
inherited SetBounds(ALeft, ATop, AWidth, AHeight); inherited SetBounds(ALeft, ATop, AWidth, AHeight);
if PositionChanged then if PositionChanged then
NotifyMoveOrResizeStarted; NotifyMoveOrResizeStarted;
end; end;

View File

@ -2,7 +2,7 @@
"UpdateLazPackages" : [ "UpdateLazPackages" : [
{ {
"ForceNotify" : true, "ForceNotify" : true,
"InternalVersion" : 338, "InternalVersion" : 339,
"Name" : "cef4delphi_lazarus.lpk", "Name" : "cef4delphi_lazarus.lpk",
"Version" : "96.0.16.0" "Version" : "96.0.16.0"
} }