1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-01-03 10:15:38 +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

@ -55,10 +55,10 @@ uses
{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE}
begin
GlobalCEFApp := TCefApplication.Create;
GlobalCEFApp.MultiThreadedMessageLoop := 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 := TCefApplication.Create;
GlobalCEFApp.FlashEnabled := False;
GlobalCEFApp.FastUnload := True;
GlobalCEFApp.OnContextInitialized := GlobalCEFApp_OnContextInitialized;
// 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
Top = 30
Width = 708
Height = 421
Height = 402
Align = alClient
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
object Chromium1: TChromium
OnLoadingStateChange = Chromium1LoadingStateChange
OnStatusMessage = Chromium1StatusMessage
OnAfterCreated = Chromium1AfterCreated
OnBeforeClose = Chromium1BeforeClose
OnClose = Chromium1Close

View File

@ -50,7 +50,7 @@ uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Menus,
Controls, Forms, Dialogs, StdCtrls, ExtCtrls, Types, ComCtrls, ClipBrd,
{$ENDIF}
uMainForm, uCEFChromium, uCEFWindowParent, uCEFInterfaces, uCEFConstants;
uMainForm, uCEFChromium, uCEFWindowParent, uCEFInterfaces, uCEFConstants, uCEFTypes;
type
TChildForm = class(TForm)
@ -59,6 +59,7 @@ type
Button1: TButton;
Chromium1: TChromium;
CEFWindowParent1: TCEFWindowParent;
StatusBar1: TStatusBar;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Chromium1AfterCreated(Sender: TObject; const browser: ICefBrowser);
procedure Button1Click(Sender: TObject);
@ -70,6 +71,11 @@ type
procedure FormDestroy(Sender: TObject);
procedure Chromium1BeforeClose(Sender: TObject;
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
// Variables to control when can we destroy the form safely
@ -121,6 +127,25 @@ begin
Result := False;
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);
begin
Action := caFree;

View File

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

View File

@ -56,6 +56,7 @@ const
CEFBROWSER_CREATED = WM_APP + $100;
CEFBROWSER_CHILDDESTROYED = WM_APP + $101;
CEFBROWSER_DESTROY = WM_APP + $102;
CEFBROWSER_INITIALIZED = WM_APP + $103;
type
TMainForm = class(TForm)
@ -66,6 +67,7 @@ type
procedure FormCreate(Sender: TObject);
procedure NewBtnClick(Sender: TObject);
procedure ExitBtnClick(Sender: TObject);
procedure FormShow(Sender: TObject);
private
// Variables to control when can we destroy the form safely
FCanClose : boolean; // Set to True when all the child forms are closed
@ -77,6 +79,7 @@ type
protected
procedure ChildDestroyedMsg(var aMessage : TMessage); message CEFBROWSER_CHILDDESTROYED;
procedure CEFInitializedMsg(var aMessage : TMessage); message CEFBROWSER_INITIALIZED;
public
function CloseQuery: Boolean; override;
@ -87,18 +90,25 @@ type
var
MainForm: TMainForm;
procedure GlobalCEFApp_OnContextInitialized;
implementation
{$R *.dfm}
uses
uChildForm;
uChildForm, uCEFApplication;
// Destruction steps
// =================
// 1. Destroy all child forms
// 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);
var
TempChild : TChildForm;
@ -171,6 +181,23 @@ begin
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;
begin
if FClosing or ChildClosing then

View File

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