1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-08-04 21:32:54 +02:00

Update to CEF 89.0.12

Modified the VCL SubProcess demo as suggested by Tomm Prami
Fixed issue #352
This commit is contained in:
Salvador Díaz Fau
2021-03-20 13:16:08 +01:00
parent 5bd415a4be
commit 0abb2732de
11 changed files with 91 additions and 101 deletions

View File

@ -3,15 +3,15 @@ CEF4Delphi is an open source project created by Salvador Díaz Fau to embed Chro
CEF4Delphi is based on DCEF3 and fpCEF3. The original license of those projects still applies to CEF4Delphi. Read the license terms in the first lines of any *.pas file. CEF4Delphi is based on DCEF3 and fpCEF3. The original license of those projects still applies to CEF4Delphi. Read the license terms in the first lines of any *.pas file.
CEF4Delphi uses CEF 89.0.7 which includes Chromium 89.0.4389.72. CEF4Delphi uses CEF 89.0.12 which includes Chromium 89.0.4389.90.
The CEF binaries used by CEF4Delphi are available for download at spotify : The CEF binaries used by CEF4Delphi are available for download at spotify :
* [Windows 32 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.7%2Bgb5952bd%2Bchromium-89.0.4389.72_windows32.tar.bz2) * [Windows 32 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.12%2Bg2b76680%2Bchromium-89.0.4389.90_windows32.tar.bz2)
* [Windows 64 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.7%2Bgb5952bd%2Bchromium-89.0.4389.72_windows64.tar.bz2) * [Windows 64 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.12%2Bg2b76680%2Bchromium-89.0.4389.90_windows64.tar.bz2)
* [Linux x86 32 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.7%2Bgb5952bd%2Bchromium-89.0.4389.72_linux32.tar.bz2) * [Linux x86 32 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.12%2Bg2b76680%2Bchromium-89.0.4389.90_linux32.tar.bz2)
* [Linux x86 64 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.7%2Bgb5952bd%2Bchromium-89.0.4389.72_linux64.tar.bz2) * [Linux x86 64 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.12%2Bg2b76680%2Bchromium-89.0.4389.90_linux64.tar.bz2)
* [Linux ARM 32 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.7%2Bgb5952bd%2Bchromium-89.0.4389.72_linuxarm.tar.bz2) * [Linux ARM 32 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.12%2Bg2b76680%2Bchromium-89.0.4389.90_linuxarm.tar.bz2)
* [Linux ARM 64 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.7%2Bgb5952bd%2Bchromium-89.0.4389.72_linuxarm64.tar.bz2) * [Linux ARM 64 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.12%2Bg2b76680%2Bchromium-89.0.4389.90_linuxarm64.tar.bz2)
* [MacOS x86 64 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.7%2Bgb5952bd%2Bchromium-89.0.4389.72_macosx64.tar.bz2) * [MacOS x86 64 bits](https://cef-builds.spotifycdn.com/cef_binary_89.0.12%2Bg2b76680%2Bchromium-89.0.4389.90_macosx64.tar.bz2)
CEF4Delphi was developed and tested on Delphi 10.4.2 and it has been tested in Delphi 7, Delphi XE, Delphi 10, Delphi 10.2, Delphi 10.3 and Lazarus 2.0.12/FPC 3.2.0. CEF4Delphi includes VCL, FireMonkey (FMX) and Lazarus components. CEF4Delphi was developed and tested on Delphi 10.4.2 and it has been tested in Delphi 7, Delphi XE, Delphi 10, Delphi 10.2, Delphi 10.3 and Lazarus 2.0.12/FPC 3.2.0. CEF4Delphi includes VCL, FireMonkey (FMX) and Lazarus components.

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit : // For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef // https://www.briskbard.com/index.php?lang=en&pageid=cef
// //
// Copyright � 2018 Salvador D�az Fau. All rights reserved. // Copyright � 2021 Salvador D�az Fau. All rights reserved.
// //
// ************************************************************************ // ************************************************************************
// ************ vvvv Original license and comments below vvvv ************* // ************ vvvv Original license and comments below vvvv *************
@ -47,17 +47,13 @@ uses
Forms, Forms,
Windows, Windows,
{$ENDIF} {$ENDIF}
uCEFApplication, uCEFLoader in 'uCEFLoader.pas',
uSimpleBrowser in 'uSimpleBrowser.pas' {Form1}, uSimpleBrowser in 'uSimpleBrowser.pas' {Form1};
uCEFLoader in 'uCEFLoader.pas';
{$R *.res} {$R *.res}
// CEF3 needs to set the LARGEADDRESSAWARE flag which allows 32-bit processes to use up to 3GB of RAM. // 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. // If you don't add this flag the rederer process will crash when you try to load large images.
// The IMAGE_FILE_LARGE_ADDRESS_AWARE constant is declared in WinApi.Windows. If you don't want to add
// WinApi.Windows to the 'uses' section in this file just replace the following line by
// {$SetPEFlags $20}
{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE} {$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE}
begin begin

View File

@ -131,10 +131,10 @@
<DelphiCompile Include="$(MainSource)"> <DelphiCompile Include="$(MainSource)">
<MainSource>MainSource</MainSource> <MainSource>MainSource</MainSource>
</DelphiCompile> </DelphiCompile>
<DCCReference Include="uCEFLoader.pas"/>
<DCCReference Include="uSimpleBrowser.pas"> <DCCReference Include="uSimpleBrowser.pas">
<Form>Form1</Form> <Form>Form1</Form>
</DCCReference> </DCCReference>
<DCCReference Include="uCEFLoader.pas"/>
<BuildConfiguration Include="Release"> <BuildConfiguration Include="Release">
<Key>Cfg_2</Key> <Key>Cfg_2</Key>
<CfgParent>Base</CfgParent> <CfgParent>Base</CfgParent>

View File

@ -10,7 +10,7 @@
// For more information about CEF4Delphi visit : // For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef // https://www.briskbard.com/index.php?lang=en&pageid=cef
// //
// Copyright © 2018 Salvador Díaz Fau. All rights reserved. // Copyright © 2021 Salvador Díaz Fau. All rights reserved.
// //
// ************************************************************************ // ************************************************************************
// ************ vvvv Original license and comments below vvvv ************* // ************ vvvv Original license and comments below vvvv *************
@ -35,7 +35,7 @@
* *
*) *)
program SubProcess; program SimpleBrowser_sp;
{$I cef.inc} {$I cef.inc}
@ -45,34 +45,22 @@ uses
{$ELSE} {$ELSE}
Windows, Windows,
{$ENDIF} {$ENDIF}
uCEFApplicationCore; uCEFLoader in 'uCEFLoader.pas';
// CEF3 needs to set the LARGEADDRESSAWARE flag which allows 32-bit processes // CEF3 needs to set the LARGEADDRESSAWARE flag which allows 32-bit processes
// to use up to 3GB of RAM. // to use up to 3GB of RAM.
{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE} {$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE}
begin begin
GlobalCEFApp := TCefApplicationCore.Create; // 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.
// The main process and the subprocess *MUST* have the same GlobalCEFApp // uCEFLoader will call CreateGlobalCEFApp and DestroyGlobalCEFApp in the
// properties and events, specially FrameworkDirPath, ResourcesDirPath, // initialization and finalization sections of that unit.
// LocalesDirPath, cache and UserDataPath paths.
// The demos are compiled into the BIN directory. Make sure SubProcess.exe
// and SimpleBrowser.exe are in that directory or this demo won't work.
// In case you want to use custom directories for the CEF3 binaries, cache
// and user data.
{
GlobalCEFApp.FrameworkDirPath := 'cef';
GlobalCEFApp.ResourcesDirPath := 'cef';
GlobalCEFApp.LocalesDirPath := 'cef\locales';
GlobalCEFApp.cache := 'cef\cache';
GlobalCEFApp.UserDataPath := 'cef\User Data';
}
GlobalCEFApp.StartSubProcess;
GlobalCEFApp.Free;
GlobalCEFApp := nil;
end. end.

View File

@ -3,7 +3,7 @@
<ProjectGuid>{6ABCF641-08D0-4F35-9D13-2FBD18E5152A}</ProjectGuid> <ProjectGuid>{6ABCF641-08D0-4F35-9D13-2FBD18E5152A}</ProjectGuid>
<ProjectVersion>19.2</ProjectVersion> <ProjectVersion>19.2</ProjectVersion>
<FrameworkType>VCL</FrameworkType> <FrameworkType>VCL</FrameworkType>
<MainSource>SubProcess.dpr</MainSource> <MainSource>SimpleBrowser_sp.dpr</MainSource>
<Base>True</Base> <Base>True</Base>
<Config Condition="'$(Config)'==''">Release</Config> <Config Condition="'$(Config)'==''">Release</Config>
<Platform Condition="'$(Platform)'==''">Win32</Platform> <Platform Condition="'$(Platform)'==''">Win32</Platform>
@ -50,7 +50,7 @@
<DCC_Namespace>System;Xml;Data;Datasnap;Web;Soap;Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;$(DCC_Namespace)</DCC_Namespace> <DCC_Namespace>System;Xml;Data;Datasnap;Web;Soap;Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;$(DCC_Namespace)</DCC_Namespace>
<VerInfo_Keys>CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=</VerInfo_Keys> <VerInfo_Keys>CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
<Icon_MainIcon>$(BDS)\bin\delphi_PROJECTICON.ico</Icon_MainIcon> <Icon_MainIcon>$(BDS)\bin\delphi_PROJECTICON.ico</Icon_MainIcon>
<SanitizedProjectName>SubProcess</SanitizedProjectName> <SanitizedProjectName>SimpleBrowser_sp</SanitizedProjectName>
<DCC_DcuOutput>.\$(Platform)\$(Config)</DCC_DcuOutput> <DCC_DcuOutput>.\$(Platform)\$(Config)</DCC_DcuOutput>
<DCC_E>false</DCC_E> <DCC_E>false</DCC_E>
<DCC_N>false</DCC_N> <DCC_N>false</DCC_N>
@ -58,6 +58,7 @@
<DCC_F>false</DCC_F> <DCC_F>false</DCC_F>
<DCC_K>false</DCC_K> <DCC_K>false</DCC_K>
<DCC_ExeOutput>..\..\..\bin</DCC_ExeOutput> <DCC_ExeOutput>..\..\..\bin</DCC_ExeOutput>
<DCC_Define>CEFSUBPROCESS;$(DCC_Define)</DCC_Define>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Base_Win32)'!=''"> <PropertyGroup Condition="'$(Base_Win32)'!=''">
<DCC_Namespace>Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace)</DCC_Namespace> <DCC_Namespace>Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace)</DCC_Namespace>
@ -112,6 +113,7 @@
<DelphiCompile Include="$(MainSource)"> <DelphiCompile Include="$(MainSource)">
<MainSource>MainSource</MainSource> <MainSource>MainSource</MainSource>
</DelphiCompile> </DelphiCompile>
<DCCReference Include="uCEFLoader.pas"/>
<BuildConfiguration Include="Release"> <BuildConfiguration Include="Release">
<Key>Cfg_2</Key> <Key>Cfg_2</Key>
<CfgParent>Base</CfgParent> <CfgParent>Base</CfgParent>
@ -130,16 +132,21 @@
<BorlandProject> <BorlandProject>
<Delphi.Personality> <Delphi.Personality>
<Source> <Source>
<Source Name="MainSource">SubProcess.dpr</Source> <Source Name="MainSource">SimpleBrowser_sp.dpr</Source>
</Source> </Source>
<Excluded_Packages> <Excluded_Packages>
<Excluded_Packages Name="$(BDSBIN)\dclIPIndyImpl260.bpl">IP Abstraction Indy Implementation Design Time</Excluded_Packages> <Excluded_Packages Name="$(BDSBIN)\dclIPIndyImpl270.bpl">IP Abstraction Indy Implementation Design Time</Excluded_Packages>
<Excluded_Packages Name="$(BDSBIN)\DataExplorerDBXPluginEnt260.bpl">DBExpress Enterprise Data Explorer Integration</Excluded_Packages> <Excluded_Packages Name="$(BDSBIN)\dcloffice2k270.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages>
<Excluded_Packages Name="$(BDSBIN)\dcloffice2k260.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages> <Excluded_Packages Name="$(BDSBIN)\dclofficexp270.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
<Excluded_Packages Name="$(BDSBIN)\dclofficexp260.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
</Excluded_Packages> </Excluded_Packages>
</Delphi.Personality> </Delphi.Personality>
<Deployment Version="3"> <Deployment Version="3">
<DeployFile LocalName="..\..\..\bin\SimpleBrowser_sp.exe" Configuration="Release" Class="ProjectOutput">
<Platform Name="Win32">
<RemoteName>SimpleBrowser_sp.exe</RemoteName>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="Win32\Debug\SubProcess.exe" Configuration="Debug" Class="ProjectOutput"/> <DeployFile LocalName="Win32\Debug\SubProcess.exe" Configuration="Debug" Class="ProjectOutput"/>
<DeployClass Name="AdditionalDebugSymbols"> <DeployClass Name="AdditionalDebugSymbols">
<Platform Name="iOSSimulator"> <Platform Name="iOSSimulator">

View File

@ -6,7 +6,7 @@
<Projects Include="SimpleBrowser.dproj"> <Projects Include="SimpleBrowser.dproj">
<Dependencies/> <Dependencies/>
</Projects> </Projects>
<Projects Include="SubProcess.dproj"> <Projects Include="SimpleBrowser_sp.dproj">
<Dependencies/> <Dependencies/>
</Projects> </Projects>
</ItemGroup> </ItemGroup>
@ -26,23 +26,23 @@
<Target Name="SimpleBrowser:Make"> <Target Name="SimpleBrowser:Make">
<MSBuild Projects="SimpleBrowser.dproj" Targets="Make"/> <MSBuild Projects="SimpleBrowser.dproj" Targets="Make"/>
</Target> </Target>
<Target Name="SubProcess"> <Target Name="SimpleBrowser_sp">
<MSBuild Projects="SubProcess.dproj"/> <MSBuild Projects="SimpleBrowser_sp.dproj"/>
</Target> </Target>
<Target Name="SubProcess:Clean"> <Target Name="SimpleBrowser_sp:Clean">
<MSBuild Projects="SubProcess.dproj" Targets="Clean"/> <MSBuild Projects="SimpleBrowser_sp.dproj" Targets="Clean"/>
</Target> </Target>
<Target Name="SubProcess:Make"> <Target Name="SimpleBrowser_sp:Make">
<MSBuild Projects="SubProcess.dproj" Targets="Make"/> <MSBuild Projects="SimpleBrowser_sp.dproj" Targets="Make"/>
</Target> </Target>
<Target Name="Build"> <Target Name="Build">
<CallTarget Targets="SimpleBrowser;SubProcess"/> <CallTarget Targets="SimpleBrowser;SimpleBrowser_sp"/>
</Target> </Target>
<Target Name="Clean"> <Target Name="Clean">
<CallTarget Targets="SimpleBrowser:Clean;SubProcess:Clean"/> <CallTarget Targets="SimpleBrowser:Clean;SimpleBrowser_sp:Clean"/>
</Target> </Target>
<Target Name="Make"> <Target Name="Make">
<CallTarget Targets="SimpleBrowser:Make;SubProcess:Make"/> <CallTarget Targets="SimpleBrowser:Make;SimpleBrowser_sp:Make"/>
</Target> </Target>
<Import Project="$(BDS)\Bin\CodeGear.Group.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Group.Targets')"/> <Import Project="$(BDS)\Bin\CodeGear.Group.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Group.Targets')"/>
</Project> </Project>

View File

@ -42,17 +42,26 @@ interface
implementation implementation
uses uses
{$IFDEF CEFSUBPROCESS}
uCEFApplicationCore;
{$ELSE}
uCEFApplication; uCEFApplication;
{$ENDIF}
// Follow these steps to test this demo :
// 1. Build the SubProcess project in this directory.
// 2. Copy the CEF binaries to the BIN directory in CEF4Delphi.
// 3. Build this project : SimpleBrowser
// 4. Run this demo : SimpleBrowser
procedure CreateGlobalCEFApp; procedure CreateGlobalCEFApp;
begin 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;
{$IFDEF CEFSUBPROCESS}
GlobalCEFApp := TCefApplicationCore.Create;
{$ELSE}
GlobalCEFApp := TCefApplication.Create; 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. // 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. // If you don't set a cache directory the browser will use in-memory cache.
@ -65,12 +74,9 @@ begin
GlobalCEFApp.UserDataPath := 'cef\User Data'; GlobalCEFApp.UserDataPath := 'cef\User Data';
} }
GlobalCEFApp.BrowserSubprocessPath := 'SubProcess.exe';
// This demo uses a different EXE for the subprocesses. // This demo uses a different EXE for the subprocesses.
// With this configuration it's not necessary to have the // With this configuration it's not necessary to have the
// GlobalCEFApp.StartMainProcess call in a if..then clause. // GlobalCEFApp.StartMainProcess call in a if..then clause.
GlobalCEFApp.StartMainProcess; GlobalCEFApp.StartMainProcess;
end; end;

View File

@ -1,7 +1,7 @@
object Form1: TForm1 object Form1: TForm1
Left = 0 Left = 0
Top = 0 Top = 0
Caption = 'Simple Browser' Caption = 'Simple Browser - Initializing browser. Please wait...'
ClientHeight = 624 ClientHeight = 624
ClientWidth = 1038 ClientWidth = 1038
Color = clBtnFace Color = clBtnFace
@ -12,8 +12,8 @@ object Form1: TForm1
Font.Style = [] Font.Style = []
OldCreateOrder = False OldCreateOrder = False
Position = poScreenCenter Position = poScreenCenter
OnActivate = FormActivate
OnCloseQuery = FormCloseQuery OnCloseQuery = FormCloseQuery
OnShow = FormShow
PixelsPerInch = 96 PixelsPerInch = 96
TextHeight = 13 TextHeight = 13
object ChromiumWindow1: TChromiumWindow object ChromiumWindow1: TChromiumWindow
@ -24,7 +24,6 @@ object Form1: TForm1
Align = alClient Align = alClient
TabOrder = 0 TabOrder = 0
OnClose = ChromiumWindow1Close OnClose = ChromiumWindow1Close
OnBeforeClose = ChromiumWindow1BeforeClose
OnAfterCreated = ChromiumWindow1AfterCreated OnAfterCreated = ChromiumWindow1AfterCreated
end end
object AddressPnl: TPanel object AddressPnl: TPanel

View File

@ -50,7 +50,7 @@ uses
Controls, Forms, Dialogs, StdCtrls, ExtCtrls, Controls, Forms, Dialogs, StdCtrls, ExtCtrls,
{$ENDIF} {$ENDIF}
uCEFChromium, uCEFWindowParent, uCEFChromiumWindow, uCEFTypes, uCEFInterfaces, uCEFChromium, uCEFWindowParent, uCEFChromiumWindow, uCEFTypes, uCEFInterfaces,
uCEFWinControl, uCEFSentinel; uCEFWinControl, uCEFSentinel, uCEFLinkedWinControlBase;
type type
TForm1 = class(TForm) TForm1 = class(TForm)
@ -60,12 +60,11 @@ type
GoBtn: TButton; GoBtn: TButton;
Timer1: TTimer; Timer1: TTimer;
procedure GoBtnClick(Sender: TObject); procedure GoBtnClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure ChromiumWindow1AfterCreated(Sender: TObject); procedure ChromiumWindow1AfterCreated(Sender: TObject);
procedure Timer1Timer(Sender: TObject); procedure Timer1Timer(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure ChromiumWindow1Close(Sender: TObject); procedure ChromiumWindow1Close(Sender: TObject);
procedure ChromiumWindow1BeforeClose(Sender: TObject); procedure FormActivate(Sender: TObject);
private private
// You have to handle this two messages to call NotifyMoveOrResizeStarted or some page elements will be misaligned. // You have to handle this two messages to call NotifyMoveOrResizeStarted or some page elements will be misaligned.
procedure WMMove(var aMessage : TWMMove); message WM_MOVE; procedure WMMove(var aMessage : TWMMove); message WM_MOVE;
@ -109,12 +108,11 @@ uses
// Destruction steps // Destruction steps
// ================= // =================
// 1. The FormCloseQuery event sets CanClose to False and calls TChromiumWindow.CloseBrowser, which triggers the TChromiumWindow.OnClose event. // 1. The FormCloseQuery event sets CanClose to False and calls TChromiumWindow.CloseBrowser, which triggers the TChromiumWindow.OnClose event.
// 2. The TChromiumWindow.OnClose event calls TChromiumWindow.DestroyChildWindow which triggers the TChromiumWindow.OnBeforeClose event. // 2. The TChromiumWindow.OnClose sets FCanClose := True and sends WM_CLOSE to the form.
// 3. TChromiumWindow.OnBeforeClose sets FCanClose := True and sends WM_CLOSE to the form.
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean); procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin begin
if GlobalCEFApp.LibLoaded then if (GlobalCEFApp <> nil) and GlobalCEFApp.LibLoaded then
begin begin
CanClose := FCanClose; CanClose := FCanClose;
@ -129,11 +127,13 @@ begin
CanClose := True; CanClose := True;
end; end;
procedure TForm1.FormShow(Sender: TObject); procedure TForm1.FormActivate(Sender: TObject);
begin begin
Caption := 'Simple Browser - Initializing browser. Please wait...'; if ChromiumWindow1.Initialized then
exit;
ChromiumWindow1.ChromiumBrowser.OnBeforePopup := Chromium_OnBeforePopup; ChromiumWindow1.ChromiumBrowser.OnBeforePopup := Chromium_OnBeforePopup;
ChromiumWindow1.ChromiumBrowser.DefaultURL := AddressEdt.Text;
// You *MUST* call CreateBrowser to create and initialize the browser. // You *MUST* call CreateBrowser to create and initialize the browser.
// This will trigger the AfterCreated event when the browser is fully // This will trigger the AfterCreated event when the browser is fully
@ -141,20 +141,11 @@ begin
// GlobalCEFApp.GlobalContextInitialized has to be TRUE before creating any browser // GlobalCEFApp.GlobalContextInitialized has to be TRUE before creating any browser
// If it's not initialized yet, we use a simple timer to create the browser later. // If it's not initialized yet, we use a simple timer to create the browser later.
if not(ChromiumWindow1.CreateBrowser) then Timer1.Enabled := True; if not(ChromiumWindow1.CreateBrowser) then
Timer1.Enabled := True;
end; end;
procedure TForm1.ChromiumWindow1Close(Sender: TObject); procedure TForm1.ChromiumWindow1Close(Sender: TObject);
begin
// DestroyChildWindow will destroy the child window created by CEF at the top of the Z order.
if not(ChromiumWindow1.DestroyChildWindow) then
begin
FCanClose := True;
PostMessage(Handle, WM_CLOSE, 0, 0);
end;
end;
procedure TForm1.ChromiumWindow1BeforeClose(Sender: TObject);
begin begin
FCanClose := True; FCanClose := True;
PostMessage(Handle, WM_CLOSE, 0, 0); PostMessage(Handle, WM_CLOSE, 0, 0);
@ -176,10 +167,9 @@ end;
procedure TForm1.ChromiumWindow1AfterCreated(Sender: TObject); procedure TForm1.ChromiumWindow1AfterCreated(Sender: TObject);
begin begin
// Now the browser is fully initialized we can load the initial web page. // Now the browser is fully initialized we can enable the user interface.
Caption := 'Simple Browser'; Caption := 'Simple Browser';
AddressPnl.Enabled := True; AddressPnl.Enabled := True;
GoBtn.Click;
end; end;
procedure TForm1.GoBtnClick(Sender: TObject); procedure TForm1.GoBtnClick(Sender: TObject);
@ -199,28 +189,32 @@ procedure TForm1.WMMove(var aMessage : TWMMove);
begin begin
inherited; inherited;
if (ChromiumWindow1 <> nil) then ChromiumWindow1.NotifyMoveOrResizeStarted; if (ChromiumWindow1 <> nil) then
ChromiumWindow1.NotifyMoveOrResizeStarted;
end; end;
procedure TForm1.WMMoving(var aMessage : TMessage); procedure TForm1.WMMoving(var aMessage : TMessage);
begin begin
inherited; inherited;
if (ChromiumWindow1 <> nil) then ChromiumWindow1.NotifyMoveOrResizeStarted; if (ChromiumWindow1 <> nil) then
ChromiumWindow1.NotifyMoveOrResizeStarted;
end; end;
procedure TForm1.WMEnterMenuLoop(var aMessage: TMessage); procedure TForm1.WMEnterMenuLoop(var aMessage: TMessage);
begin begin
inherited; inherited;
if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := True; if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then
GlobalCEFApp.OsmodalLoop := True;
end; end;
procedure TForm1.WMExitMenuLoop(var aMessage: TMessage); procedure TForm1.WMExitMenuLoop(var aMessage: TMessage);
begin begin
inherited; inherited;
if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := False; if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then
GlobalCEFApp.OsmodalLoop := False;
end; end;
end. end.

View File

@ -66,13 +66,13 @@ uses
const const
CEF_SUPPORTED_VERSION_MAJOR = 89; CEF_SUPPORTED_VERSION_MAJOR = 89;
CEF_SUPPORTED_VERSION_MINOR = 0; CEF_SUPPORTED_VERSION_MINOR = 0;
CEF_SUPPORTED_VERSION_RELEASE = 7; CEF_SUPPORTED_VERSION_RELEASE = 12;
CEF_SUPPORTED_VERSION_BUILD = 0; CEF_SUPPORTED_VERSION_BUILD = 0;
CEF_CHROMEELF_VERSION_MAJOR = 89; CEF_CHROMEELF_VERSION_MAJOR = 89;
CEF_CHROMEELF_VERSION_MINOR = 0; CEF_CHROMEELF_VERSION_MINOR = 0;
CEF_CHROMEELF_VERSION_RELEASE = 4389; CEF_CHROMEELF_VERSION_RELEASE = 4389;
CEF_CHROMEELF_VERSION_BUILD = 72; CEF_CHROMEELF_VERSION_BUILD = 90;
{$IFDEF MSWINDOWS} {$IFDEF MSWINDOWS}
LIBCEF_DLL = 'libcef.dll'; LIBCEF_DLL = 'libcef.dll';

View File

@ -2,9 +2,9 @@
"UpdateLazPackages" : [ "UpdateLazPackages" : [
{ {
"ForceNotify" : true, "ForceNotify" : true,
"InternalVersion" : 269, "InternalVersion" : 270,
"Name" : "cef4delphi_lazarus.lpk", "Name" : "cef4delphi_lazarus.lpk",
"Version" : "89.0.7.0" "Version" : "89.0.12.0"
} }
], ],
"UpdatePackageData" : { "UpdatePackageData" : {