1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-05-23 21:50:21 +02:00

Added timers to create the browsers only when GlobalCEFApp.GlobalContextInitialized is TRUE

This commit is contained in:
Salvador Díaz Fau 2017-11-04 18:32:29 +01:00
parent 92c167a1da
commit d138e98ecb
23 changed files with 220 additions and 46 deletions

View File

@ -72,4 +72,11 @@ object CookieVisitorFrm: TCookieVisitorFrm
Left = 32
Top = 224
end
object Timer1: TTimer
Enabled = False
Interval = 300
OnTimer = Timer1Timer
Left = 32
Top = 280
end
end

View File

@ -65,6 +65,7 @@ type
GoBtn: TButton;
CEFWindowParent1: TCEFWindowParent;
Chromium1: TChromium;
Timer1: TTimer;
procedure Chromium1AfterCreated(Sender: TObject; const browser: ICefBrowser);
procedure FormShow(Sender: TObject);
procedure GoBtnClick(Sender: TObject);
@ -79,6 +80,7 @@ type
numDeleted: Integer);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
procedure WMMove(var aMessage : TWMMove); message WM_MOVE;
@ -163,6 +165,12 @@ begin
SimpleTextViewerFrm.ShowModal;
end;
procedure TCookieVisitorFrm.Timer1Timer(Sender: TObject);
begin
Timer1.Enabled := False;
if not(Chromium1.CreateBrowser(CEFWindowParent1, '')) then Timer1.Enabled := True;
end;
procedure TCookieVisitorFrm.GoBtnClick(Sender: TObject);
begin
Chromium1.LoadURL(Edit1.Text);
@ -221,7 +229,9 @@ end;
procedure TCookieVisitorFrm.FormShow(Sender: TObject);
begin
Chromium1.CreateBrowser(CEFWindowParent1, '');
// 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 not(Chromium1.CreateBrowser(CEFWindowParent1, '')) then Timer1.Enabled := True;
end;
procedure TCookieVisitorFrm.WMMove(var aMessage : TWMMove);

View File

@ -22,10 +22,6 @@ object MainForm: TMainForm
Height = 628
Align = alClient
TabOrder = 0
ExplicitLeft = 184
ExplicitTop = 168
ExplicitWidth = 100
ExplicitHeight = 41
end
object AddressBarPnl: TPanel
Left = 0
@ -43,8 +39,6 @@ object MainForm: TMainForm
ParentDoubleBuffered = False
ShowCaption = False
TabOrder = 1
ExplicitLeft = -620
ExplicitWidth = 1038
object Edit1: TEdit
Left = 5
Top = 5
@ -54,7 +48,6 @@ object MainForm: TMainForm
Align = alClient
TabOrder = 0
Text = 'http://www.example.com'
ExplicitWidth = 997
ExplicitHeight = 21
end
object Button1: TButton
@ -67,7 +60,13 @@ object MainForm: TMainForm
Caption = 'Go'
TabOrder = 1
OnClick = Button1Click
ExplicitLeft = 1002
end
end
object Timer1: TTimer
Enabled = False
Interval = 300
OnTimer = Timer1Timer
Left = 48
Top = 240
end
end

View File

@ -57,9 +57,11 @@ type
AddressBarPnl: TPanel;
Edit1: TEdit;
Button1: TButton;
Timer1: TTimer;
procedure FormShow(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
procedure WMMove(var aMessage : TWMMove); message WM_MOVE;
@ -92,7 +94,16 @@ procedure TMainForm.FormShow(Sender: TObject);
begin
ChromiumWindow1.OnAfterCreated := Chromium_OnAfterCreated;
ChromiumWindow1.ChromiumBrowser.OnGetResourceHandler := Chromium_OnGetResourceHandler;
ChromiumWindow1.CreateBrowser;
// 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 not(ChromiumWindow1.CreateBrowser) then Timer1.Enabled := True;
end;
procedure TMainForm.Timer1Timer(Sender: TObject);
begin
Timer1.Enabled := False;
if not(ChromiumWindow1.CreateBrowser) then Timer1.Enabled := True;
end;
procedure TMainForm.Chromium_OnAfterCreated(Sender: TObject);

View File

@ -22,7 +22,6 @@ object DOMVisitorFrm: TDOMVisitorFrm
Height = 530
Align = alClient
TabOrder = 0
ExplicitHeight = 549
end
object AddressBarPnl: TPanel
Left = 0
@ -71,9 +70,6 @@ object DOMVisitorFrm: TDOMVisitorFrm
item
Width = 50
end>
ExplicitLeft = 584
ExplicitTop = 552
ExplicitWidth = 0
end
object Chromium1: TChromium
OnProcessMessageReceived = Chromium1ProcessMessageReceived
@ -83,4 +79,11 @@ object DOMVisitorFrm: TDOMVisitorFrm
Left = 16
Top = 40
end
object Timer1: TTimer
Enabled = False
Interval = 300
OnTimer = Timer1Timer
Left = 16
Top = 96
end
end

View File

@ -68,6 +68,7 @@ type
GoBtn: TButton;
AddressEdt: TEdit;
StatusBar1: TStatusBar;
Timer1: TTimer;
procedure GoBtnClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Chromium1AfterCreated(Sender: TObject;
@ -82,6 +83,7 @@ type
procedure Chromium1ProcessMessageReceived(Sender: TObject;
const browser: ICefBrowser; sourceProcess: TCefProcessId;
const message: ICefProcessMessage; out Result: Boolean);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
protected
@ -148,7 +150,9 @@ end;
procedure TDOMVisitorFrm.FormShow(Sender: TObject);
begin
Chromium1.CreateBrowser(CEFWindowParent1, '');
// 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 not(Chromium1.CreateBrowser(CEFWindowParent1, '')) then Timer1.Enabled := True;
end;
procedure TDOMVisitorFrm.GoBtnClick(Sender: TObject);
@ -192,4 +196,10 @@ begin
StatusBar1.Panels[0].Text := aText;
end;
procedure TDOMVisitorFrm.Timer1Timer(Sender: TObject);
begin
Timer1.Enabled := False;
if not(Chromium1.CreateBrowser(CEFWindowParent1, '')) then Timer1.Enabled := True;
end;
end.

View File

@ -33,4 +33,11 @@ object MainForm: TMainForm
Left = 208
Top = 120
end
object Timer1: TTimer
Enabled = False
Interval = 300
OnTimer = Timer1Timer
Left = 272
Top = 120
end
end

View File

@ -48,12 +48,14 @@ uses
Windows, Messages, SysUtils, Variants, Classes, Graphics,
Controls, Forms, Dialogs,
{$ENDIF}
uCEFChromium, uCEFWindowParent, uCEFInterfaces, uCEFTypes, uCEFConstants;
uCEFChromium, uCEFWindowParent, uCEFInterfaces, uCEFTypes, uCEFConstants,
Vcl.ExtCtrls;
type
TMainForm = class(TForm)
CEFWindowParent1: TCEFWindowParent;
Chromium1: TChromium;
Timer1: TTimer;
procedure Chromium1PreKeyEvent(Sender: TObject;
const browser: ICefBrowser; const event: PCefKeyEvent; osEvent: PMsg;
out isKeyboardShortcut, Result: Boolean);
@ -63,6 +65,7 @@ type
procedure FormShow(Sender: TObject);
procedure Chromium1AfterCreated(Sender: TObject;
const browser: ICefBrowser);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
protected
@ -101,6 +104,12 @@ begin
end;
end;
procedure TMainForm.Timer1Timer(Sender: TObject);
begin
Timer1.Enabled := False;
if not(Chromium1.CreateBrowser(CEFWindowParent1, '')) then Timer1.Enabled := True;
end;
procedure TMainForm.HandleKeyDown(const aMsg : TMsg; var aHandled : boolean);
var
TempMessage : TMessage;
@ -165,7 +174,10 @@ end;
procedure TMainForm.FormShow(Sender: TObject);
begin
Chromium1.DefaultUrl := 'https://www.google.com';
Chromium1.CreateBrowser(CEFWindowParent1, '');
// 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 not(Chromium1.CreateBrowser(CEFWindowParent1, '')) then Timer1.Enabled := True;
end;
procedure TMainForm.WMMove(var aMessage : TWMMove);

View File

@ -22,7 +22,6 @@ object GeolocationFrm: TGeolocationFrm
Height = 642
Align = alClient
TabOrder = 0
ExplicitHeight = 395
end
object NavControlPnl: TPanel
Left = 0
@ -76,13 +75,17 @@ object GeolocationFrm: TGeolocationFrm
item
Width = 200
end>
ExplicitLeft = 584
ExplicitTop = 592
ExplicitWidth = 0
end
object Chromium1: TChromium
OnAfterCreated = Chromium1AfterCreated
Left = 32
Top = 224
end
object Timer1: TTimer
Enabled = False
Interval = 300
OnTimer = Timer1Timer
Left = 32
Top = 288
end
end

View File

@ -62,10 +62,12 @@ type
Edit1: TEdit;
GoBtn: TButton;
StatusBar1: TStatusBar;
Timer1: TTimer;
procedure Chromium1AfterCreated(Sender: TObject; const browser: ICefBrowser);
procedure GoBtnClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
protected
procedure BrowserCreatedMsg(var aMessage : TMessage); message CEF_AFTERCREATED;
procedure NewLocationMsg(var aMessage : TMessage); message MINIBROWSER_NEWLOCATION;
@ -88,7 +90,9 @@ end;
procedure TGeolocationFrm.FormShow(Sender: TObject);
begin
Chromium1.CreateBrowser(CEFWindowParent1, '');
// 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 not(Chromium1.CreateBrowser(CEFWindowParent1, '')) then Timer1.Enabled := True;
end;
procedure TGeolocationFrm.GoBtnClick(Sender: TObject);
@ -110,6 +114,12 @@ begin
StatusBar1.Panels[2].Text := 'alt : ' + floattostr(GlobalPosition.altitude);
end;
procedure TGeolocationFrm.Timer1Timer(Sender: TObject);
begin
Timer1.Enabled := False;
if not(Chromium1.CreateBrowser(CEFWindowParent1, '')) then Timer1.Enabled := True;
end;
procedure TGeolocationFrm.WMMove(var aMessage : TWMMove);
begin
inherited;

View File

@ -69,4 +69,11 @@ object JSEvalFrm: TJSEvalFrm
Left = 16
Top = 40
end
object Timer1: TTimer
Enabled = False
Interval = 300
OnTimer = Timer1Timer
Left = 16
Top = 96
end
end

View File

@ -70,6 +70,7 @@ type
AddressBarPnl: TPanel;
GoBtn: TButton;
AddressEdt: TEdit;
Timer1: TTimer;
procedure Chromium1AfterCreated(Sender: TObject; const browser: ICefBrowser);
procedure GoBtnClick(Sender: TObject);
procedure FormShow(Sender: TObject);
@ -84,6 +85,7 @@ type
const browser: ICefBrowser; const frame: ICefFrame;
const params: ICefContextMenuParams; commandId: Integer;
eventFlags: Cardinal; out Result: Boolean);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
@ -189,7 +191,9 @@ end;
procedure TJSEvalFrm.FormShow(Sender: TObject);
begin
Chromium1.CreateBrowser(CEFWindowParent1, '');
// 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 not(Chromium1.CreateBrowser(CEFWindowParent1, '')) then Timer1.Enabled := True;
end;
procedure TJSEvalFrm.GoBtnClick(Sender: TObject);
@ -210,6 +214,12 @@ begin
SimpleTextViewerFrm.ShowModal;
end;
procedure TJSEvalFrm.Timer1Timer(Sender: TObject);
begin
Timer1.Enabled := False;
if not(Chromium1.CreateBrowser(CEFWindowParent1, '')) then Timer1.Enabled := True;
end;
procedure TJSEvalFrm.WMMove(var aMessage : TWMMove);
begin
inherited;

View File

@ -90,6 +90,9 @@ begin
GlobalCEFApp.FrameworkDirPath := 'cef';
GlobalCEFApp.ResourcesDirPath := 'cef';
GlobalCEFApp.LocalesDirPath := 'cef\locales';
GlobalCEFApp.EnableGPU := True; // Enable hardware acceleration
GlobalCEFApp.DisableGPUCache := True; // Disable the creation of a 'GPUCache' directory in the hard drive.
GlobalCEFApp.SingleProcess := True; // Use the single process mode *ONLY* for debugging purposes
GlobalCEFApp.cache := 'cef\cache';
GlobalCEFApp.cookies := 'cef\cookies';
GlobalCEFApp.UserDataPath := 'cef\User Data';

View File

@ -78,4 +78,11 @@ object JSExtensionFrm: TJSExtensionFrm
Left = 32
Top = 224
end
object Timer1: TTimer
Enabled = False
Interval = 300
OnTimer = Timer1Timer
Left = 32
Top = 288
end
end

View File

@ -68,6 +68,7 @@ type
StatusBar1: TStatusBar;
CEFWindowParent1: TCEFWindowParent;
Chromium1: TChromium;
Timer1: TTimer;
procedure FormShow(Sender: TObject);
procedure GoBtnClick(Sender: TObject);
procedure Chromium1BeforeContextMenu(Sender: TObject;
@ -81,6 +82,7 @@ type
const browser: ICefBrowser; sourceProcess: TCefProcessId;
const message: ICefProcessMessage; out Result: Boolean);
procedure Chromium1AfterCreated(Sender: TObject; const browser: ICefBrowser);
procedure Timer1Timer(Sender: TObject);
protected
FText : string;
@ -205,7 +207,11 @@ end;
procedure TJSExtensionFrm.FormShow(Sender: TObject);
begin
Chromium1.CreateBrowser(CEFWindowParent1, '');
StatusBar1.Panels[0].Text := 'Initializing browser. Please wait...';
// 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 not(Chromium1.CreateBrowser(CEFWindowParent1, '')) then Timer1.Enabled := True;
end;
procedure TJSExtensionFrm.WMMove(var aMessage : TWMMove);
@ -229,8 +235,15 @@ begin
SimpleTextViewerFrm.ShowModal;
end;
procedure TJSExtensionFrm.Timer1Timer(Sender: TObject);
begin
Timer1.Enabled := False;
if not(Chromium1.CreateBrowser(CEFWindowParent1, '')) then Timer1.Enabled := True;
end;
procedure TJSExtensionFrm.BrowserCreatedMsg(var aMessage : TMessage);
begin
StatusBar1.Panels[0].Text := '';
CEFWindowParent1.UpdateSize;
NavControlPnl.Enabled := True;
GoBtn.Click;

View File

@ -24,9 +24,6 @@ object PostDataInspectorFrm: TPostDataInspectorFrm
item
Width = 50
end>
ExplicitLeft = -119
ExplicitTop = 548
ExplicitWidth = 978
end
object CEFWindowParent1: TCEFWindowParent
Left = 0
@ -35,10 +32,6 @@ object PostDataInspectorFrm: TPostDataInspectorFrm
Height = 666
Align = alClient
TabOrder = 1
ExplicitLeft = -119
ExplicitTop = 27
ExplicitWidth = 978
ExplicitHeight = 540
end
object NavControlPnl: TPanel
Left = 0
@ -54,8 +47,6 @@ object PostDataInspectorFrm: TPostDataInspectorFrm
Padding.Bottom = 5
ShowCaption = False
TabOrder = 2
ExplicitLeft = -119
ExplicitWidth = 978
object Edit1: TEdit
Left = 5
Top = 5
@ -67,7 +58,6 @@ object PostDataInspectorFrm: TPostDataInspectorFrm
Text =
'https://www.w3schools.com/php/showphp.asp?filename=demo_form_pos' +
't'
ExplicitWidth = 937
ExplicitHeight = 21
end
object GoBtn: TButton
@ -80,7 +70,6 @@ object PostDataInspectorFrm: TPostDataInspectorFrm
Caption = 'Go'
TabOrder = 1
OnClick = GoBtnClick
ExplicitLeft = 942
end
end
object Chromium1: TChromium
@ -89,4 +78,11 @@ object PostDataInspectorFrm: TPostDataInspectorFrm
Left = 32
Top = 224
end
object Timer1: TTimer
Enabled = False
Interval = 300
OnTimer = Timer1Timer
Left = 32
Top = 288
end
end

View File

@ -62,6 +62,7 @@ type
NavControlPnl: TPanel;
Edit1: TEdit;
GoBtn: TButton;
Timer1: TTimer;
procedure GoBtnClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Chromium1ProcessMessageReceived(Sender: TObject;
@ -69,6 +70,7 @@ type
const message: ICefProcessMessage; out Result: Boolean);
procedure Chromium1AfterCreated(Sender: TObject;
const browser: ICefBrowser);
procedure Timer1Timer(Sender: TObject);
protected
procedure BrowserCreatedMsg(var aMessage : TMessage); message CEF_AFTERCREATED;
@ -124,7 +126,9 @@ end;
procedure TPostDataInspectorFrm.FormShow(Sender: TObject);
begin
Chromium1.CreateBrowser(CEFWindowParent1, '');
// 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 not(Chromium1.CreateBrowser(CEFWindowParent1, '')) then Timer1.Enabled := True;
end;
procedure TPostDataInspectorFrm.GoBtnClick(Sender: TObject);
@ -132,6 +136,12 @@ begin
Chromium1.LoadURL(Edit1.Text);
end;
procedure TPostDataInspectorFrm.Timer1Timer(Sender: TObject);
begin
Timer1.Enabled := False;
if not(Chromium1.CreateBrowser(CEFWindowParent1, '')) then Timer1.Enabled := True;
end;
procedure TPostDataInspectorFrm.WMMove(var aMessage : TWMMove);
begin
inherited;

View File

@ -31,7 +31,6 @@ object SchemeRegistrationBrowserFrm: TSchemeRegistrationBrowserFrm
ParentDoubleBuffered = False
ShowCaption = False
TabOrder = 0
ExplicitWidth = 865
object GoBtn: TButton
Left = 944
Top = 5
@ -42,7 +41,6 @@ object SchemeRegistrationBrowserFrm: TSchemeRegistrationBrowserFrm
Caption = 'Go'
TabOrder = 0
OnClick = GoBtnClick
ExplicitLeft = 829
end
object AddressCbx: TComboBox
Left = 5
@ -65,8 +63,6 @@ object SchemeRegistrationBrowserFrm: TSchemeRegistrationBrowserFrm
Height = 622
Align = alClient
TabOrder = 1
ExplicitWidth = 865
ExplicitHeight = 528
end
object Chromium1: TChromium
OnBeforeContextMenu = Chromium1BeforeContextMenu
@ -75,4 +71,11 @@ object SchemeRegistrationBrowserFrm: TSchemeRegistrationBrowserFrm
Left = 16
Top = 40
end
object Timer1: TTimer
Enabled = False
Interval = 300
OnTimer = Timer1Timer
Left = 16
Top = 96
end
end

View File

@ -63,6 +63,7 @@ type
CEFWindowParent1: TCEFWindowParent;
Chromium1: TChromium;
AddressCbx: TComboBox;
Timer1: TTimer;
procedure Chromium1AfterCreated(Sender: TObject;
const browser: ICefBrowser);
procedure Chromium1BeforeContextMenu(Sender: TObject;
@ -74,6 +75,7 @@ type
eventFlags: Cardinal; out Result: Boolean);
procedure GoBtnClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
protected
@ -141,7 +143,9 @@ end;
procedure TSchemeRegistrationBrowserFrm.FormShow(Sender: TObject);
begin
Chromium1.CreateBrowser(CEFWindowParent1, '');
// 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 not(Chromium1.CreateBrowser(CEFWindowParent1, '')) then Timer1.Enabled := True;
end;
procedure TSchemeRegistrationBrowserFrm.GoBtnClick(Sender: TObject);
@ -149,6 +153,12 @@ begin
Chromium1.LoadURL(AddressCbx.Text);
end;
procedure TSchemeRegistrationBrowserFrm.Timer1Timer(Sender: TObject);
begin
Timer1.Enabled := False;
if not(Chromium1.CreateBrowser(CEFWindowParent1, '')) then Timer1.Enabled := True;
end;
procedure TSchemeRegistrationBrowserFrm.BrowserCreatedMsg(var aMessage : TMessage);
begin
CEFWindowParent1.UpdateSize;

View File

@ -141,7 +141,14 @@ object Form1: TForm1
DefaultExt = 'bmp'
Filter = 'Bitmap files (*.bmp)|*.BMP'
Title = 'Save snapshot'
Left = 544
Top = 62
Left = 24
Top = 278
end
object Timer1: TTimer
Enabled = False
Interval = 300
OnTimer = Timer1Timer
Left = 24
Top = 206
end
end

View File

@ -64,6 +64,7 @@ type
GoBtn: TButton;
SnapshotBtn: TButton;
SaveDialog1: TSaveDialog;
Timer1: TTimer;
procedure AppEventsMessage(var Msg: tagMSG; var Handled: Boolean);
@ -94,6 +95,7 @@ type
procedure chrmosrPopupSize(Sender: TObject; const browser: ICefBrowser; const rect: PCefRect);
procedure chrmosrAfterCreated(Sender: TObject; const browser: ICefBrowser);
procedure SnapshotBtnClick(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
function getModifiers(Shift: TShiftState): TCefEventFlags;
@ -467,8 +469,11 @@ begin
else
begin
chrmosr.Options.BackgroundColor := CefColorSetARGB($FF, $FF, $FF, $FF); // opaque white background color
chrmosr.CreateBrowser(nil, '');
chrmosr.InitializeDragAndDrop(PaintBox);
if chrmosr.CreateBrowser(nil, '') then
chrmosr.InitializeDragAndDrop(PaintBox)
else
Timer1.Enabled := True;
end;
end;
@ -575,4 +580,14 @@ begin
if SaveDialog1.Execute then PaintBox.Buffer.SaveToFile(SaveDialog1.FileName);
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Timer1.Enabled := False;
if chrmosr.CreateBrowser(nil, '') then
chrmosr.InitializeDragAndDrop(PaintBox)
else
Timer1.Enabled := True;
end;
end.

View File

@ -61,4 +61,11 @@ object Form1: TForm1
OnClick = GoBtnClick
end
end
object Timer1: TTimer
Enabled = False
Interval = 300
OnTimer = Timer1Timer
Left = 80
Top = 88
end
end

View File

@ -57,9 +57,11 @@ type
AddressPnl: TPanel;
AddressEdt: TEdit;
GoBtn: TButton;
Timer1: TTimer;
procedure GoBtnClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure ChromiumWindow1AfterCreated(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
// 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;
@ -89,15 +91,21 @@ implementation
procedure TForm1.FormShow(Sender: TObject);
begin
Caption := 'Simple Browser - Initializing browser. Please wait...';
// You *MUST* call CreateBrowser to create and initialize the browser.
// This will trigger the AfterCreated event when the browser is fully
// initialized and ready to receive commands.
ChromiumWindow1.CreateBrowser;
// 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 not(ChromiumWindow1.CreateBrowser) then Timer1.Enabled := True;
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;
@ -108,6 +116,12 @@ begin
ChromiumWindow1.LoadURL(AddressEdt.Text);
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Timer1.Enabled := False;
if not(ChromiumWindow1.CreateBrowser) then Timer1.Enabled := True;
end;
procedure TForm1.WMMove(var aMessage : TWMMove);
begin
inherited;