1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-01-13 10:22:04 +02:00

Update to CEF 3.3202.1694.gf061c23

- fixed MDIBrowser demo and added some crude initialization checks
This commit is contained in:
Salvador Díaz Fau 2017-12-14 10:31:24 +01:00
parent 49a1c9af3a
commit afa069b776
6 changed files with 83 additions and 9 deletions

View File

@ -56,9 +56,9 @@ uses
begin begin
GlobalCEFApp := TCefApplication.Create; GlobalCEFApp := TCefApplication.Create;
GlobalCEFApp.MultiThreadedMessageLoop := False;
GlobalCEFApp.FlashEnabled := False; GlobalCEFApp.FlashEnabled := False;
GlobalCEFApp.FastUnload := True; // Enable the fast unload controller, which speeds up tab/window close by running a tab's onunload js handler independently of the GUI GlobalCEFApp.FastUnload := True;
GlobalCEFApp.OnContextInitialized := GlobalCEFApp_OnContextInitialized;
// In case you want to use custom directories for the CEF3 binaries, cache, cookies and user data. // In case you want to use custom directories for the CEF3 binaries, cache, cookies and user data.
{ {

View File

@ -58,11 +58,30 @@ object ChildForm: TChildForm
Left = 0 Left = 0
Top = 30 Top = 30
Width = 708 Width = 708
Height = 421 Height = 402
Align = alClient Align = alClient
TabOrder = 1 TabOrder = 1
ExplicitHeight = 421
end
object StatusBar1: TStatusBar
Left = 0
Top = 432
Width = 708
Height = 19
Panels = <
item
Width = 100
end
item
Width = 500
end>
ExplicitLeft = 360
ExplicitTop = 424
ExplicitWidth = 0
end end
object Chromium1: TChromium object Chromium1: TChromium
OnLoadingStateChange = Chromium1LoadingStateChange
OnStatusMessage = Chromium1StatusMessage
OnAfterCreated = Chromium1AfterCreated OnAfterCreated = Chromium1AfterCreated
OnBeforeClose = Chromium1BeforeClose OnBeforeClose = Chromium1BeforeClose
OnClose = Chromium1Close OnClose = Chromium1Close

View File

@ -50,7 +50,7 @@ uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Menus, Windows, Messages, SysUtils, Variants, Classes, Graphics, Menus,
Controls, Forms, Dialogs, StdCtrls, ExtCtrls, Types, ComCtrls, ClipBrd, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, Types, ComCtrls, ClipBrd,
{$ENDIF} {$ENDIF}
uMainForm, uCEFChromium, uCEFWindowParent, uCEFInterfaces, uCEFConstants; uMainForm, uCEFChromium, uCEFWindowParent, uCEFInterfaces, uCEFConstants, uCEFTypes;
type type
TChildForm = class(TForm) TChildForm = class(TForm)
@ -59,6 +59,7 @@ type
Button1: TButton; Button1: TButton;
Chromium1: TChromium; Chromium1: TChromium;
CEFWindowParent1: TCEFWindowParent; CEFWindowParent1: TCEFWindowParent;
StatusBar1: TStatusBar;
procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Chromium1AfterCreated(Sender: TObject; const browser: ICefBrowser); procedure Chromium1AfterCreated(Sender: TObject; const browser: ICefBrowser);
procedure Button1Click(Sender: TObject); procedure Button1Click(Sender: TObject);
@ -70,6 +71,11 @@ type
procedure FormDestroy(Sender: TObject); procedure FormDestroy(Sender: TObject);
procedure Chromium1BeforeClose(Sender: TObject; procedure Chromium1BeforeClose(Sender: TObject;
const browser: ICefBrowser); const browser: ICefBrowser);
procedure Chromium1LoadingStateChange(Sender: TObject;
const browser: ICefBrowser; isLoading, canGoBack,
canGoForward: Boolean);
procedure Chromium1StatusMessage(Sender: TObject;
const browser: ICefBrowser; const value: ustring);
private private
// Variables to control when can we destroy the form safely // Variables to control when can we destroy the form safely
@ -121,6 +127,25 @@ begin
Result := False; Result := False;
end; end;
procedure TChildForm.Chromium1LoadingStateChange(Sender: TObject; const browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean);
begin
if isLoading then
begin
StatusBar1.Panels[0].Text := 'Loading...';
cursor := crAppStart;
end
else
begin
StatusBar1.Panels[0].Text := '';
cursor := crDefault;
end;
end;
procedure TChildForm.Chromium1StatusMessage(Sender: TObject; const browser: ICefBrowser; const value: ustring);
begin
StatusBar1.Panels[1].Text := value;
end;
procedure TChildForm.FormClose(Sender: TObject; var Action: TCloseAction); procedure TChildForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin begin
Action := caFree; Action := caFree;

View File

@ -1,7 +1,8 @@
object MainForm: TMainForm object MainForm: TMainForm
Left = 194 Left = 194
Top = 111 Top = 111
Caption = 'MDI Application' Cursor = crAppStart
Caption = 'Initializing browser. Please wait...'
ClientHeight = 631 ClientHeight = 631
ClientWidth = 709 ClientWidth = 709
Color = clAppWorkSpace Color = clAppWorkSpace
@ -14,6 +15,7 @@ object MainForm: TMainForm
OldCreateOrder = False OldCreateOrder = False
Position = poScreenCenter Position = poScreenCenter
OnCreate = FormCreate OnCreate = FormCreate
OnShow = FormShow
PixelsPerInch = 96 PixelsPerInch = 96
TextHeight = 13 TextHeight = 13
object ButtonPnl: TPanel object ButtonPnl: TPanel
@ -23,6 +25,7 @@ object MainForm: TMainForm
Height = 30 Height = 30
Align = alTop Align = alTop
BevelOuter = bvNone BevelOuter = bvNone
Enabled = False
ShowCaption = False ShowCaption = False
TabOrder = 0 TabOrder = 0
object NewBtn: TSpeedButton object NewBtn: TSpeedButton

View File

@ -56,6 +56,7 @@ const
CEFBROWSER_CREATED = WM_APP + $100; CEFBROWSER_CREATED = WM_APP + $100;
CEFBROWSER_CHILDDESTROYED = WM_APP + $101; CEFBROWSER_CHILDDESTROYED = WM_APP + $101;
CEFBROWSER_DESTROY = WM_APP + $102; CEFBROWSER_DESTROY = WM_APP + $102;
CEFBROWSER_INITIALIZED = WM_APP + $103;
type type
TMainForm = class(TForm) TMainForm = class(TForm)
@ -66,6 +67,7 @@ type
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
procedure NewBtnClick(Sender: TObject); procedure NewBtnClick(Sender: TObject);
procedure ExitBtnClick(Sender: TObject); procedure ExitBtnClick(Sender: TObject);
procedure FormShow(Sender: TObject);
private private
// Variables to control when can we destroy the form safely // Variables to control when can we destroy the form safely
FCanClose : boolean; // Set to True when all the child forms are closed FCanClose : boolean; // Set to True when all the child forms are closed
@ -77,6 +79,7 @@ type
protected protected
procedure ChildDestroyedMsg(var aMessage : TMessage); message CEFBROWSER_CHILDDESTROYED; procedure ChildDestroyedMsg(var aMessage : TMessage); message CEFBROWSER_CHILDDESTROYED;
procedure CEFInitializedMsg(var aMessage : TMessage); message CEFBROWSER_INITIALIZED;
public public
function CloseQuery: Boolean; override; function CloseQuery: Boolean; override;
@ -87,18 +90,25 @@ type
var var
MainForm: TMainForm; MainForm: TMainForm;
procedure GlobalCEFApp_OnContextInitialized;
implementation implementation
{$R *.dfm} {$R *.dfm}
uses uses
uChildForm; uChildForm, uCEFApplication;
// Destruction steps // Destruction steps
// ================= // =================
// 1. Destroy all child forms // 1. Destroy all child forms
// 2. Wait until all the child forms are closed before closing the main form and terminating the application. // 2. Wait until all the child forms are closed before closing the main form and terminating the application.
procedure GlobalCEFApp_OnContextInitialized;
begin
if (MainForm <> nil) then PostMessage(MainForm.Handle, CEFBROWSER_INITIALIZED, 0, 0);
end;
procedure TMainForm.CreateMDIChild(const Name: string); procedure TMainForm.CreateMDIChild(const Name: string);
var var
TempChild : TChildForm; TempChild : TChildForm;
@ -171,6 +181,23 @@ begin
end; end;
end; end;
procedure TMainForm.CEFInitializedMsg(var aMessage : TMessage);
begin
Caption := 'MDI Browser';
ButtonPnl.Enabled := True;
cursor := crDefault;
end;
procedure TMainForm.FormShow(Sender: TObject);
begin
if (GlobalCEFApp <> nil) and GlobalCEFApp.GlobalContextInitialized then
begin
Caption := 'MDI Browser';
ButtonPnl.Enabled := True;
cursor := crDefault;
end;
end;
function TMainForm.CloseQuery: Boolean; function TMainForm.CloseQuery: Boolean;
begin begin
if FClosing or ChildClosing then if FClosing or ChildClosing then

View File

@ -57,7 +57,7 @@ uses
const const
CEF_SUPPORTED_VERSION_MAJOR = 3; CEF_SUPPORTED_VERSION_MAJOR = 3;
CEF_SUPPORTED_VERSION_MINOR = 3202; CEF_SUPPORTED_VERSION_MINOR = 3202;
CEF_SUPPORTED_VERSION_RELEASE = 1693; CEF_SUPPORTED_VERSION_RELEASE = 1694;
CEF_SUPPORTED_VERSION_BUILD = 0; CEF_SUPPORTED_VERSION_BUILD = 0;
CEF_CHROMEELF_VERSION_MAJOR = 62; CEF_CHROMEELF_VERSION_MAJOR = 62;