You've already forked CEF4Delphi
mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2025-11-23 21:34:53 +02:00
Update to CEF 88.2.9
Added the SimpleBrowser demo for Linux. Added Linux support to TChromiumWindow. Removed unused code and added more code comments to the SimpleBrowser demos for Windows.
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
// For more information about CEF4Delphi visit :
|
||||
// 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 *************
|
||||
@@ -50,9 +50,11 @@ uses
|
||||
|
||||
{$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 IMAGE_FILE_LARGE_ADDRESS_AWARE}
|
||||
{$ENDIF}
|
||||
|
||||
begin
|
||||
GlobalCEFApp := TCefApplication.Create;
|
||||
|
||||
@@ -26,7 +26,6 @@ object Form1: TForm1
|
||||
TabStop = True
|
||||
TabOrder = 0
|
||||
OnClose = ChromiumWindow1Close
|
||||
OnBeforeClose = ChromiumWindow1BeforeClose
|
||||
OnAfterCreated = ChromiumWindow1AfterCreated
|
||||
end
|
||||
object AddressPnl: TPanel
|
||||
|
||||
@@ -69,7 +69,6 @@ type
|
||||
|
||||
procedure ChromiumWindow1AfterCreated(Sender: TObject);
|
||||
procedure ChromiumWindow1Close(Sender: TObject);
|
||||
procedure ChromiumWindow1BeforeClose(Sender: TObject);
|
||||
|
||||
private
|
||||
// You have to handle this two messages to call NotifyMoveOrResizeStarted or some page elements will be misaligned.
|
||||
@@ -81,7 +80,7 @@ type
|
||||
|
||||
protected
|
||||
// Variables to control when can we destroy the form safely
|
||||
FCanClose : boolean; // Set to True in TChromium.OnBeforeClose
|
||||
FCanClose : boolean; // Set to True in TChromium.OnClose
|
||||
FClosing : boolean; // Set to True in the CloseQuery event.
|
||||
|
||||
procedure Chromium_OnBeforePopup(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; const popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; var extra_info: ICefDictionaryValue; var noJavascriptAccess: Boolean; var Result: Boolean);
|
||||
@@ -108,15 +107,19 @@ uses
|
||||
|
||||
// Depending on your internet connection it may take longer than expected.
|
||||
|
||||
// This demo uses a TChromiumWindow component which should *ONLY* be used for extremely
|
||||
// simple applications with a simple browser. For any other configuration it's
|
||||
// recommended using a TChromium with a TCEFWindowParent as shown in the SimpleBrowser2 demo.
|
||||
|
||||
// Please check that your firewall or antivirus are not blocking this application
|
||||
// or the domain "google.com". If you don't live in the US, you'll be redirected to
|
||||
// another domain which will take a little time too.
|
||||
|
||||
// Destruction steps
|
||||
// =================
|
||||
// 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.
|
||||
// 3. TChromiumWindow.OnBeforeClose sets FCanClose := True and sends WM_CLOSE to the form.
|
||||
// 1. The FormCloseQuery event sets CanClose to False and calls TChromiumWindow.CloseBrowser,
|
||||
// which triggers the TChromiumWindow.OnClose event.
|
||||
// 2. The TChromiumWindow.OnClose sets FCanClose to true and sends WM_CLOSE to the form.
|
||||
|
||||
|
||||
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
||||
@@ -135,6 +138,9 @@ procedure TForm1.FormCreate(Sender: TObject);
|
||||
begin
|
||||
FCanClose := False;
|
||||
FClosing := False;
|
||||
|
||||
// The browser will load the URL in AddressEdt initially.
|
||||
ChromiumWindow1.ChromiumBrowser.DefaultURL := AddressEdt.Text;
|
||||
end;
|
||||
|
||||
procedure TForm1.FormShow(Sender: TObject);
|
||||
@@ -151,22 +157,12 @@ begin
|
||||
if not(ChromiumWindow1.CreateBrowser) then Timer1.Enabled := True;
|
||||
end;
|
||||
|
||||
procedure TForm1.ChromiumWindow1BeforeClose(Sender: TObject);
|
||||
procedure TForm1.ChromiumWindow1Close(Sender: TObject);
|
||||
begin
|
||||
FCanClose := True;
|
||||
PostMessage(Handle, WM_CLOSE, 0, 0);
|
||||
end;
|
||||
|
||||
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.Chromium_OnBeforePopup( Sender : TObject;
|
||||
const browser : ICefBrowser;
|
||||
const frame : ICefFrame;
|
||||
@@ -188,10 +184,8 @@ end;
|
||||
|
||||
procedure TForm1.ChromiumWindow1AfterCreated(Sender: TObject);
|
||||
begin
|
||||
// Now the browser is fully initialized we can load the initial web page.
|
||||
Caption := 'Simple Browser';
|
||||
AddressPnl.Enabled := True;
|
||||
GoBtn.Click;
|
||||
end;
|
||||
|
||||
procedure TForm1.GoBtnClick(Sender: TObject);
|
||||
|
||||
Reference in New Issue
Block a user