mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2025-04-07 06:50:04 +02:00
Fixed context menu position in FMX demos using OSR mode in high DPI screens
Fixed a build issue in the SubProcess demo.
This commit is contained in:
parent
7f3e3415ef
commit
676162a41b
@ -588,10 +588,11 @@ procedure TFMXExternalPumpBrowserFrm.chrmosrGetScreenPoint( Sender : TObje
|
||||
out Result : Boolean);
|
||||
var
|
||||
TempScreenPt, TempViewPt : TPoint;
|
||||
TempScale : single;
|
||||
begin
|
||||
// TFMXBufferPanel.ClientToScreen applies the scale factor. No need to call LogicalToDevice to set TempViewPt.
|
||||
TempViewPt.x := viewX;
|
||||
TempViewPt.y := viewY;
|
||||
TempScale := Panel1.ScreenScale;
|
||||
TempViewPt.x := LogicalToDevice(viewX, TempScale);
|
||||
TempViewPt.y := LogicalToDevice(viewY, TempScale);
|
||||
TempScreenPt := Panel1.ClientToScreen(TempViewPt);
|
||||
screenX := TempScreenPt.x;
|
||||
screenY := TempScreenPt.y;
|
||||
|
@ -578,8 +578,8 @@ procedure TMainForm.chrmosrGetScreenPoint( Sender : TObject;
|
||||
var
|
||||
TempPoint : TPointF;
|
||||
begin
|
||||
TempPoint.x := viewX;
|
||||
TempPoint.y := viewY;
|
||||
TempPoint.x := LogicalToDevice(viewX, GlobalCEFApp.DeviceScaleFactor);
|
||||
TempPoint.y := LogicalToDevice(viewY, GlobalCEFApp.DeviceScaleFactor);
|
||||
// LocalToScreen applies the scale factor. No need to call LogicalToDevice to set TempViewPt.
|
||||
TempPoint := Panel1.LocalToScreen(TempPoint);
|
||||
screenX := round(TempPoint.x);
|
||||
|
@ -213,6 +213,7 @@ begin
|
||||
if (FPopUpBitmap <> nil) then FreeAndNil(FPopUpBitmap);
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TBrowserFrame.ReloadBtnClick(Sender: TObject);
|
||||
begin
|
||||
FMXChromium1.Reload;
|
||||
@ -222,6 +223,7 @@ procedure TBrowserFrame.FocusBrowser;
|
||||
begin
|
||||
FMXBufferPanel1.SetFocus;
|
||||
end;
|
||||
|
||||
procedure TBrowserFrame.ResizeBrowser;
|
||||
begin
|
||||
try
|
||||
@ -244,6 +246,7 @@ begin
|
||||
if (FResizeCS <> nil) then FResizeCS.Release;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TBrowserFrame.NotifyMoveOrResizeStarted;
|
||||
begin
|
||||
FMXChromium1.NotifyMoveOrResizeStarted;
|
||||
@ -490,10 +493,11 @@ procedure TBrowserFrame.FMXChromium1GetScreenPoint(Sender: TObject;
|
||||
screenY: Integer; out Result: Boolean);
|
||||
var
|
||||
TempScreenPt, TempViewPt : TPoint;
|
||||
TempScale : single;
|
||||
begin
|
||||
// TFMXBufferPanel.ClientToScreen applies the scale factor. No need to call LogicalToDevice to set TempViewPt.
|
||||
TempViewPt.x := viewX;
|
||||
TempViewPt.y := viewY;
|
||||
TempScale := FMXBufferPanel1.ScreenScale;
|
||||
TempViewPt.x := LogicalToDevice(viewX, TempScale);
|
||||
TempViewPt.y := LogicalToDevice(viewY, TempScale);
|
||||
TempScreenPt := FMXBufferPanel1.ClientToScreen(TempViewPt);
|
||||
screenX := TempScreenPt.x;
|
||||
screenY := TempScreenPt.y;
|
||||
|
@ -40,21 +40,17 @@ program SimpleBrowser;
|
||||
{$I cef.inc}
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
Vcl.Forms,
|
||||
WinApi.Windows,
|
||||
{$ELSE}
|
||||
Forms,
|
||||
Windows,
|
||||
{$ENDIF}
|
||||
uCEFLoader in 'uCEFLoader.pas',
|
||||
uSimpleBrowser in 'uSimpleBrowser.pas' {Form1};
|
||||
|
||||
{$R *.res}
|
||||
|
||||
// CEF3 needs to set the LARGEADDRESSAWARE flag which allows 32-bit processes to use up to 3GB of RAM.
|
||||
// If you don't add this flag the rederer process will crash when you try to load large images.
|
||||
{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE}
|
||||
{$IFDEF WIN32}
|
||||
// CEF3 needs to set the LARGEADDRESSAWARE flag which allows 32-bit processes to use up to 3GB of RAM.
|
||||
// If you don't add this flag the rederer process will crash when you try to load large images.
|
||||
{$SetPEFlags $20}
|
||||
{$ENDIF}
|
||||
|
||||
begin
|
||||
// This demo has the GlobalCEFApp creation, initialization and destruction in uCEFLoader.pas
|
||||
|
@ -1,7 +1,7 @@
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>{55E00327-9D98-4DA3-A4E1-844942A01C6B}</ProjectGuid>
|
||||
<ProjectVersion>19.3</ProjectVersion>
|
||||
<ProjectVersion>19.4</ProjectVersion>
|
||||
<FrameworkType>VCL</FrameworkType>
|
||||
<MainSource>SimpleBrowser.dpr</MainSource>
|
||||
<Base>True</Base>
|
||||
@ -162,13 +162,13 @@
|
||||
</Excluded_Packages>
|
||||
</Delphi.Personality>
|
||||
<Deployment Version="3">
|
||||
<DeployFile LocalName="Win32\Debug\SimpleBrowser.exe" Configuration="Debug" Class="ProjectOutput"/>
|
||||
<DeployFile LocalName="..\..\bin\SimpleBrowser.exe" Configuration="Debug" Class="ProjectOutput">
|
||||
<Platform Name="Win32">
|
||||
<RemoteName>SimpleBrowser.exe</RemoteName>
|
||||
<Overwrite>true</Overwrite>
|
||||
</Platform>
|
||||
</DeployFile>
|
||||
<DeployFile LocalName="Win32\Debug\SimpleBrowser.exe" Configuration="Debug" Class="ProjectOutput"/>
|
||||
<DeployClass Name="AdditionalDebugSymbols">
|
||||
<Platform Name="iOSSimulator">
|
||||
<Operation>1</Operation>
|
||||
@ -1294,17 +1294,17 @@
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
</DeployClass>
|
||||
<ProjectRoot Platform="OSX32" Name="$(PROJECTNAME).app"/>
|
||||
<ProjectRoot Platform="OSX64" Name="$(PROJECTNAME).app"/>
|
||||
<ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"/>
|
||||
<ProjectRoot Platform="Android64" Name="$(PROJECTNAME)"/>
|
||||
<ProjectRoot Platform="Android" Name="$(PROJECTNAME)"/>
|
||||
<ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
|
||||
<ProjectRoot Platform="OSXARM64" Name="$(PROJECTNAME).app"/>
|
||||
<ProjectRoot Platform="Android64" Name="$(PROJECTNAME)"/>
|
||||
<ProjectRoot Platform="iOSDevice32" Name="$(PROJECTNAME).app"/>
|
||||
<ProjectRoot Platform="iOSDevice64" Name="$(PROJECTNAME).app"/>
|
||||
<ProjectRoot Platform="Linux64" Name="$(PROJECTNAME)"/>
|
||||
<ProjectRoot Platform="iOSSimulator" Name="$(PROJECTNAME).app"/>
|
||||
<ProjectRoot Platform="Linux64" Name="$(PROJECTNAME)"/>
|
||||
<ProjectRoot Platform="OSX32" Name="$(PROJECTNAME).app"/>
|
||||
<ProjectRoot Platform="OSX64" Name="$(PROJECTNAME).app"/>
|
||||
<ProjectRoot Platform="OSXARM64" Name="$(PROJECTNAME).app"/>
|
||||
<ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"/>
|
||||
<ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
|
||||
</Deployment>
|
||||
<Platforms>
|
||||
<Platform value="Win32">True</Platform>
|
||||
|
@ -35,26 +35,18 @@
|
||||
*
|
||||
*)
|
||||
program SimpleBrowser_sp;
|
||||
{$I cef.inc}
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
WinApi.Windows,
|
||||
{$ELSE}
|
||||
Windows,
|
||||
{$ENDIF}
|
||||
uCEFLoader in 'uCEFLoader.pas';
|
||||
|
||||
// CEF3 needs to set the LARGEADDRESSAWARE flag which allows 32-bit processes
|
||||
// to use up to 3GB of RAM.
|
||||
{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE}
|
||||
{$I cef.inc}
|
||||
|
||||
uses
|
||||
uCEFLoader_sp in 'uCEFLoader_sp.pas';
|
||||
|
||||
{$IFDEF WIN32}
|
||||
// CEF3 needs to set the LARGEADDRESSAWARE flag which allows 32-bit processes to use up to 3GB of RAM.
|
||||
// If you don't add this flag the rederer process will crash when you try to load large images.
|
||||
{$SetPEFlags $20}
|
||||
{$ENDIF}
|
||||
|
||||
begin
|
||||
// This SubProcess project is only used for the CEF subprocesses and it needs
|
||||
// to declare "CEFSUBPROCESS" conditional define. Follow these steps to add it:
|
||||
// 1. Open the project options in the Project->Options menu option and select
|
||||
// "Building->Delphi Compiler" on the left.
|
||||
// 2. Select "All configurations - All platforms" option as the "Target" on
|
||||
// the right section of that window.
|
||||
// 3. Add "CEFSUBPROCESS" (without quotes) in the "Conditional defines" box.
|
||||
// uCEFLoader will call CreateGlobalCEFApp and DestroyGlobalCEFApp in the
|
||||
// initialization and finalization sections of that unit.
|
||||
// This SubProcess project is only used for the CEF subprocesses.
|
||||
end.
|
||||
|
@ -1,7 +1,7 @@
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>{6ABCF641-08D0-4F35-9D13-2FBD18E5152A}</ProjectGuid>
|
||||
<ProjectVersion>19.3</ProjectVersion>
|
||||
<ProjectVersion>19.4</ProjectVersion>
|
||||
<FrameworkType>VCL</FrameworkType>
|
||||
<MainSource>SimpleBrowser_sp.dpr</MainSource>
|
||||
<Base>True</Base>
|
||||
@ -58,7 +58,6 @@
|
||||
<DCC_F>false</DCC_F>
|
||||
<DCC_K>false</DCC_K>
|
||||
<DCC_ExeOutput>..\..\..\bin</DCC_ExeOutput>
|
||||
<DCC_Define>CEFSUBPROCESS;$(DCC_Define)</DCC_Define>
|
||||
<DCC_UnitSearchPath>..\..\..\source;$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Base_Win32)'!=''">
|
||||
@ -115,7 +114,7 @@
|
||||
<DelphiCompile Include="$(MainSource)">
|
||||
<MainSource>MainSource</MainSource>
|
||||
</DelphiCompile>
|
||||
<DCCReference Include="uCEFLoader.pas"/>
|
||||
<DCCReference Include="uCEFLoader_sp.pas"/>
|
||||
<BuildConfiguration Include="Base">
|
||||
<Key>Base</Key>
|
||||
</BuildConfiguration>
|
||||
@ -137,11 +136,18 @@
|
||||
<Source Name="MainSource">SimpleBrowser_sp.dpr</Source>
|
||||
</Source>
|
||||
<Excluded_Packages>
|
||||
<Excluded_Packages Name="$(BDSBIN)\dclIPIndyImpl280.bpl">IP Abstraction Indy Implementation Design Time</Excluded_Packages>
|
||||
<Excluded_Packages Name="$(BDSBIN)\dcloffice2k280.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages>
|
||||
<Excluded_Packages Name="$(BDSBIN)\dclofficexp280.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
|
||||
</Excluded_Packages>
|
||||
</Delphi.Personality>
|
||||
<Deployment Version="3">
|
||||
<DeployFile LocalName="..\..\..\bin\SimpleBrowser_sp.exe" Configuration="Debug" Class="ProjectOutput">
|
||||
<Platform Name="Win32">
|
||||
<RemoteName>SimpleBrowser_sp.exe</RemoteName>
|
||||
<Overwrite>true</Overwrite>
|
||||
</Platform>
|
||||
</DeployFile>
|
||||
<DeployFile LocalName="..\..\..\bin\SimpleBrowser_sp.exe" Configuration="Release" Class="ProjectOutput">
|
||||
<Platform Name="Win32">
|
||||
<RemoteName>SimpleBrowser_sp.exe</RemoteName>
|
||||
@ -1274,17 +1280,17 @@
|
||||
<Operation>1</Operation>
|
||||
</Platform>
|
||||
</DeployClass>
|
||||
<ProjectRoot Platform="OSX32" Name="$(PROJECTNAME).app"/>
|
||||
<ProjectRoot Platform="OSX64" Name="$(PROJECTNAME).app"/>
|
||||
<ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"/>
|
||||
<ProjectRoot Platform="Android64" Name="$(PROJECTNAME)"/>
|
||||
<ProjectRoot Platform="Android" Name="$(PROJECTNAME)"/>
|
||||
<ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
|
||||
<ProjectRoot Platform="OSXARM64" Name="$(PROJECTNAME).app"/>
|
||||
<ProjectRoot Platform="Android64" Name="$(PROJECTNAME)"/>
|
||||
<ProjectRoot Platform="iOSDevice32" Name="$(PROJECTNAME).app"/>
|
||||
<ProjectRoot Platform="iOSDevice64" Name="$(PROJECTNAME).app"/>
|
||||
<ProjectRoot Platform="Linux64" Name="$(PROJECTNAME)"/>
|
||||
<ProjectRoot Platform="iOSSimulator" Name="$(PROJECTNAME).app"/>
|
||||
<ProjectRoot Platform="Linux64" Name="$(PROJECTNAME)"/>
|
||||
<ProjectRoot Platform="OSX32" Name="$(PROJECTNAME).app"/>
|
||||
<ProjectRoot Platform="OSX64" Name="$(PROJECTNAME).app"/>
|
||||
<ProjectRoot Platform="OSXARM64" Name="$(PROJECTNAME).app"/>
|
||||
<ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"/>
|
||||
<ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
|
||||
</Deployment>
|
||||
<Platforms>
|
||||
<Platform value="Win32">True</Platform>
|
||||
|
@ -42,11 +42,7 @@ interface
|
||||
implementation
|
||||
|
||||
uses
|
||||
{$IFDEF CEFSUBPROCESS}
|
||||
uCEFApplicationCore;
|
||||
{$ELSE}
|
||||
uCEFApplication;
|
||||
{$ENDIF}
|
||||
|
||||
procedure CreateGlobalCEFApp;
|
||||
begin
|
||||
@ -56,12 +52,8 @@ begin
|
||||
if (GlobalCEFApp <> nil) then
|
||||
exit;
|
||||
|
||||
{$IFDEF CEFSUBPROCESS}
|
||||
GlobalCEFApp := TCefApplicationCore.Create;
|
||||
{$ELSE}
|
||||
GlobalCEFApp := TCefApplication.Create;
|
||||
GlobalCEFApp.BrowserSubprocessPath := 'SimpleBrowser_sp.exe';
|
||||
{$ENDIF}
|
||||
|
||||
// In case you want to use custom directories for the CEF binaries, cache and user data.
|
||||
// If you don't set a cache directory the browser will use in-memory cache.
|
||||
|
80
demos/Delphi_VCL/SubProcess/uCEFLoader_sp.pas
Normal file
80
demos/Delphi_VCL/SubProcess/uCEFLoader_sp.pas
Normal file
@ -0,0 +1,80 @@
|
||||
// ************************************************************************
|
||||
// ***************************** CEF4Delphi *******************************
|
||||
// ************************************************************************
|
||||
//
|
||||
// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based
|
||||
// browser in Delphi applications.
|
||||
//
|
||||
// The original license of DCEF3 still applies to CEF4Delphi.
|
||||
//
|
||||
// For more information about CEF4Delphi visit :
|
||||
// https://www.briskbard.com/index.php?lang=en&pageid=cef
|
||||
//
|
||||
// Copyright © 2022 Salvador Diaz Fau. All rights reserved.
|
||||
//
|
||||
// ************************************************************************
|
||||
// ************ vvvv Original license and comments below vvvv *************
|
||||
// ************************************************************************
|
||||
(*
|
||||
* Delphi Chromium Embedded 3
|
||||
*
|
||||
* Usage allowed under the restrictions of the Lesser GNU General Public License
|
||||
* or alternatively the restrictions of the Mozilla Public License 1.1
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
||||
* the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* Unit owner : Henri Gourvest <hgourvest@gmail.com>
|
||||
* Web site : http://www.progdigy.com
|
||||
* Repository : http://code.google.com/p/delphichromiumembedded/
|
||||
* Group : http://groups.google.com/group/delphichromiumembedded
|
||||
*
|
||||
* Embarcadero Technologies, Inc is not permitted to use or redistribute
|
||||
* this source code without explicit permission.
|
||||
*
|
||||
*)
|
||||
|
||||
unit uCEFLoader_sp;
|
||||
|
||||
interface
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
uCEFApplicationCore;
|
||||
|
||||
procedure CreateGlobalCEFApp;
|
||||
begin
|
||||
// In case you prefer to call CreateGlobalCEFApp and DestroyGlobalCEFApp manually
|
||||
// you have to remember that GlobalCEFApp can only be initialized *ONCE* per process.
|
||||
// This is a CEF requirement and there's no workaround.
|
||||
if (GlobalCEFApp <> nil) then
|
||||
exit;
|
||||
|
||||
GlobalCEFApp := TCefApplicationCore.Create;
|
||||
|
||||
// In case you want to use custom directories for the CEF binaries, cache and user data.
|
||||
// If you don't set a cache directory the browser will use in-memory cache.
|
||||
// The cache and user data directories must be writable.
|
||||
{
|
||||
GlobalCEFApp.FrameworkDirPath := 'cef';
|
||||
GlobalCEFApp.ResourcesDirPath := 'cef';
|
||||
GlobalCEFApp.LocalesDirPath := 'cef\locales';
|
||||
GlobalCEFApp.cache := 'cef\cache';
|
||||
GlobalCEFApp.UserDataPath := 'cef\User Data';
|
||||
}
|
||||
|
||||
// This demo uses a different EXE for the subprocesses.
|
||||
// With this configuration it's not necessary to have the
|
||||
// GlobalCEFApp.StartMainProcess call in a if..then clause.
|
||||
GlobalCEFApp.StartSubProcess;
|
||||
end;
|
||||
|
||||
initialization
|
||||
CreateGlobalCEFApp;
|
||||
|
||||
finalization
|
||||
DestroyGlobalCEFApp;
|
||||
|
||||
end.
|
Loading…
x
Reference in New Issue
Block a user