Added more comments in the SimpleBrowser demo

This commit is contained in:
Salvador Díaz Fau 2017-10-05 10:35:27 +02:00
parent 5f88acb5d0
commit 92f683662c
5 changed files with 95 additions and 73 deletions

View File

@ -51,12 +51,14 @@ uses
{$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.
{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE} {$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE}
begin begin
GlobalCEFApp := TCefApplication.Create; GlobalCEFApp := TCefApplication.Create;
// 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.
// If you don't set a cache directory the browser will use in-memory cache.
{ {
GlobalCEFApp.FrameworkDirPath := 'cef'; GlobalCEFApp.FrameworkDirPath := 'cef';
GlobalCEFApp.ResourcesDirPath := 'cef'; GlobalCEFApp.ResourcesDirPath := 'cef';
@ -66,6 +68,9 @@ begin
GlobalCEFApp.UserDataPath := 'cef\User Data'; GlobalCEFApp.UserDataPath := 'cef\User Data';
} }
// You *MUST* call GlobalCEFApp.StartMainProcess in a if..then clause
// with the Application initialization inside the begin..end.
// Read this https://www.briskbard.com/index.php?lang=en&pageid=cef
if GlobalCEFApp.StartMainProcess then if GlobalCEFApp.StartMainProcess then
begin begin
Application.Initialize; Application.Initialize;

View File

@ -11,24 +11,24 @@ File_8=TSourceModule,'c:\program files\embarcadero\studio\17.0\SOURCE\VCL\Vcl.Fo
File_9=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFLifeSpanHandler.pas',0,1,99,1,121,0,0,, File_9=TSourceModule,'C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\source\uCEFLifeSpanHandler.pas',0,1,99,1,121,0,0,,
[Modules] [Modules]
Module0=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\SimpleBrowser\SimpleBrowser.dproj Module0=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\SimpleBrowser\uSimpleBrowser.pas
Module1=default.htm Module1=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\SimpleBrowser\SimpleBrowser.dproj
Module2=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\SimpleBrowser\uSimpleBrowser.pas Module2=default.htm
Count=3 Count=3
EditWindowCount=1 EditWindowCount=1
[C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\SimpleBrowser\uSimpleBrowser.pas]
ModuleType=TSourceModule
[C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\SimpleBrowser\SimpleBrowser.dproj] [C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\SimpleBrowser\SimpleBrowser.dproj]
ModuleType=TBaseProject ModuleType=TBaseProject
[default.htm] [default.htm]
ModuleType=TURLModule ModuleType=TURLModule
[C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\SimpleBrowser\uSimpleBrowser.pas]
ModuleType=TSourceModule
[EditWindow0] [EditWindow0]
ViewCount=3 ViewCount=3
CurrentEditView=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\SimpleBrowser\SimpleBrowser.dpr CurrentEditView=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\SimpleBrowser\uSimpleBrowser.pas
View0=0 View0=0
View1=1 View1=1
View2=2 View2=2
@ -48,18 +48,17 @@ ClientHeight=9417
DockedToMainForm=1 DockedToMainForm=1
BorlandEditorCodeExplorer=BorlandEditorCodeExplorer@EditWindow0 BorlandEditorCodeExplorer=BorlandEditorCodeExplorer@EditWindow0
TopPanelSize=0 TopPanelSize=0
LeftPanelSize=1898 LeftPanelSize=0
LeftPanelClients=PropertyInspector,DockSite3
LeftPanelData=000008000101000000001615000000000000016A0700000000000001000000005D0E000009000000446F636B53697465330100000000471D00001100000050726F7065727479496E73706563746F72FFFFFFFF
RightPanelSize=2000 RightPanelSize=2000
RightPanelClients=DockSite2,DockSite4 RightPanelClients=DockSite2,DockSite4
RightPanelData=00000800010100000000161500000000000001D00700000000000001000000004312000009000000446F636B53697465320100000000471D000009000000446F636B5369746534FFFFFFFF RightPanelData=00000800010100000000A21900000000000001D00700000000000001000000004312000009000000446F636B536974653201000000009723000009000000446F636B5369746534FFFFFFFF
BottomPanelSize=1551 BottomPanelSize=0
BottomPanelClients=DockSite1,MessageView BottomPanelClients=DockSite1,MessageView
BottomPanelData=0000080001020100000009000000446F636B53697465313B36000000000000020F0600000000000001000000003B3600000F0000004D65737361676556696577466F726DFFFFFFFF BottomPanelData=0000080001020200000009000000446F636B53697465310F0000004D65737361676556696577466F726D3B36000000000000020F0600000000000001000000003B3600000F0000004D65737361676556696577466F726DFFFFFFFF
BottomMiddlePanelSize=0 BottomMiddlePanelSize=0
BottomMiddlePanelClients=DockSite0,GraphDrawingModel BottomMiddlePanelClients=DockSite0,GraphDrawingModel
BottomMiddelPanelData=0000080001020200000009000000446F636B536974653010000000477261706844726177696E67566965779D1D00000000000002F306000000000000FFFFFFFF BottomMiddelPanelData=0000080001020200000009000000446F636B536974653010000000477261706844726177696E67566965779D1D00000000000002F306000000000000FFFFFFFF
TabDockLeftClients=PropertyInspector=0,DockSite3=1
[View0] [View0]
CustomEditViewType=TWelcomePageView CustomEditViewType=TWelcomePageView
@ -68,8 +67,8 @@ WelcomePageURL=bds:/default.htm
[View1] [View1]
CustomEditViewType=TEditView CustomEditViewType=TEditView
Module=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\SimpleBrowser\SimpleBrowser.dpr Module=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\SimpleBrowser\SimpleBrowser.dpr
CursorX=2 CursorX=63
CursorY=60 CursorY=72
TopLine=37 TopLine=37
LeftCol=1 LeftCol=1
Elisions= Elisions=
@ -79,9 +78,9 @@ EditViewName=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\d
[View2] [View2]
CustomEditViewType=TEditView CustomEditViewType=TEditView
Module=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\SimpleBrowser\uSimpleBrowser.pas Module=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\SimpleBrowser\uSimpleBrowser.pas
CursorX=66 CursorX=97
CursorY=70 CursorY=57
TopLine=44 TopLine=42
LeftCol=1 LeftCol=1
Elisions= Elisions=
Bookmarks= Bookmarks=
@ -104,11 +103,11 @@ State=0
Left=0 Left=0
Top=0 Top=0
Width=3820 Width=3820
Height=1121 Height=1143
MaxLeft=-1 MaxLeft=-1
MaxTop=-1 MaxTop=-1
ClientWidth=3820 ClientWidth=3820
ClientHeight=1121 ClientHeight=1143
TBDockHeight=213 TBDockHeight=213
LRDockWidth=13602 LRDockWidth=13602
Dockable=1 Dockable=1
@ -165,7 +164,7 @@ StayOnTop=0
[MessageView] [MessageView]
PercentageSizes=1 PercentageSizes=1
Create=1 Create=1
Visible=1 Visible=0
Docked=1 Docked=1
State=0 State=0
Left=0 Left=0
@ -190,11 +189,11 @@ State=0
Left=0 Left=0
Top=0 Top=0
Width=2000 Width=2000
Height=2713 Height=4383
MaxLeft=-1 MaxLeft=-1
MaxTop=-1 MaxTop=-1
ClientWidth=2000 ClientWidth=2000
ClientHeight=2713 ClientHeight=4383
TBDockHeight=7152 TBDockHeight=7152
LRDockWidth=2000 LRDockWidth=2000
Dockable=1 Dockable=1
@ -244,8 +243,8 @@ Create=1
Visible=0 Visible=0
Docked=1 Docked=1
State=0 State=0
Left=-121 Left=-148
Top=-70 Top=-132
Width=1844 Width=1844
Height=3139 Height=3139
MaxLeft=-1 MaxLeft=-1
@ -298,7 +297,7 @@ StayOnTop=0
[PropertyInspector] [PropertyInspector]
PercentageSizes=1 PercentageSizes=1
Create=1 Create=1
Visible=1 Visible=0
Docked=1 Docked=1
State=0 State=0
Left=0 Left=0
@ -309,7 +308,7 @@ MaxLeft=-1
MaxTop=-1 MaxTop=-1
ClientWidth=1898 ClientWidth=1898
ClientHeight=3744 ClientHeight=3744
TBDockHeight=7164 TBDockHeight=7220
LRDockWidth=1898 LRDockWidth=1898
Dockable=1 Dockable=1
StayOnTop=0 StayOnTop=0
@ -324,11 +323,11 @@ State=0
Left=0 Left=0
Top=0 Top=0
Width=2000 Width=2000
Height=6883 Height=6939
MaxLeft=-1 MaxLeft=-1
MaxTop=-1 MaxTop=-1
ClientWidth=2000 ClientWidth=2000
ClientHeight=6883 ClientHeight=6939
TBDockHeight=5964 TBDockHeight=5964
LRDockWidth=2508 LRDockWidth=2508
Dockable=1 Dockable=1
@ -340,8 +339,8 @@ Create=1
Visible=0 Visible=0
Docked=1 Docked=1
State=0 State=0
Left=-946 Left=-898
Top=5 Top=-132
Width=2844 Width=2844
Height=6200 Height=6200
MaxLeft=-1 MaxLeft=-1
@ -359,8 +358,8 @@ Create=1
Visible=0 Visible=0
Docked=1 Docked=1
State=0 State=0
Left=-1152 Left=-1026
Top=247 Top=-132
Width=273 Width=273
Height=359 Height=359
MaxLeft=-1 MaxLeft=-1
@ -384,11 +383,11 @@ State=0
Left=0 Left=0
Top=0 Top=0
Width=3820 Width=3820
Height=1121 Height=1143
MaxLeft=-1 MaxLeft=-1
MaxTop=-1 MaxTop=-1
ClientWidth=3820 ClientWidth=3820
ClientHeight=1121 ClientHeight=1143
TBDockHeight=415 TBDockHeight=415
LRDockWidth=4953 LRDockWidth=4953
Dockable=1 Dockable=1
@ -403,11 +402,11 @@ State=0
Left=0 Left=0
Top=0 Top=0
Width=3820 Width=3820
Height=1121 Height=1143
MaxLeft=-1 MaxLeft=-1
MaxTop=-1 MaxTop=-1
ClientWidth=3820 ClientWidth=3820
ClientHeight=1121 ClientHeight=1143
TBDockHeight=213 TBDockHeight=213
LRDockWidth=7406 LRDockWidth=7406
Dockable=1 Dockable=1
@ -426,11 +425,11 @@ State=0
Left=0 Left=0
Top=0 Top=0
Width=3820 Width=3820
Height=1121 Height=1143
MaxLeft=-1 MaxLeft=-1
MaxTop=-1 MaxTop=-1
ClientWidth=3820 ClientWidth=3820
ClientHeight=1121 ClientHeight=1143
TBDockHeight=1536 TBDockHeight=1536
LRDockWidth=3484 LRDockWidth=3484
Dockable=1 Dockable=1
@ -445,11 +444,11 @@ State=0
Left=0 Left=0
Top=0 Top=0
Width=3820 Width=3820
Height=1121 Height=1143
MaxLeft=-1 MaxLeft=-1
MaxTop=-1 MaxTop=-1
ClientWidth=3820 ClientWidth=3820
ClientHeight=1121 ClientHeight=1143
TBDockHeight=2063 TBDockHeight=2063
LRDockWidth=3484 LRDockWidth=3484
Dockable=1 Dockable=1
@ -483,11 +482,11 @@ State=0
Left=0 Left=0
Top=0 Top=0
Width=2336 Width=2336
Height=964 Height=1200
MaxLeft=-1 MaxLeft=-1
MaxTop=-1 MaxTop=-1
ClientWidth=2336 ClientWidth=2336
ClientHeight=964 ClientHeight=1200
TBDockHeight=2321 TBDockHeight=2321
LRDockWidth=2820 LRDockWidth=2820
Dockable=1 Dockable=1
@ -548,11 +547,11 @@ State=0
Left=0 Left=0
Top=0 Top=0
Width=2000 Width=2000
Height=6883 Height=6939
MaxLeft=-1 MaxLeft=-1
MaxTop=-1 MaxTop=-1
ClientWidth=2000 ClientWidth=2000
ClientHeight=6883 ClientHeight=6939
TBDockHeight=4888 TBDockHeight=4888
LRDockWidth=7148 LRDockWidth=7148
Dockable=1 Dockable=1
@ -564,8 +563,8 @@ Create=1
Visible=0 Visible=0
Docked=1 Docked=1
State=0 State=0
Left=249 Left=0
Top=709 Top=0
Width=2859 Width=2859
Height=3206 Height=3206
MaxLeft=-1 MaxLeft=-1
@ -586,11 +585,11 @@ State=0
Left=0 Left=0
Top=0 Top=0
Width=3820 Width=3820
Height=1121 Height=1143
MaxLeft=-1 MaxLeft=-1
MaxTop=-1 MaxTop=-1
ClientWidth=3820 ClientWidth=3820
ClientHeight=1121 ClientHeight=1143
TBDockHeight=1547 TBDockHeight=1547
LRDockWidth=8742 LRDockWidth=8742
Dockable=1 Dockable=1
@ -612,11 +611,11 @@ State=0
Left=0 Left=0
Top=0 Top=0
Width=1898 Width=1898
Height=3554 Height=7545
MaxLeft=-1 MaxLeft=-1
MaxTop=-1 MaxTop=-1
ClientWidth=1898 ClientWidth=1898
ClientHeight=3554 ClientHeight=7545
TBDockHeight=3677 TBDockHeight=3677
LRDockWidth=1898 LRDockWidth=1898
Dockable=1 Dockable=1
@ -631,11 +630,11 @@ State=0
Left=0 Left=0
Top=0 Top=0
Width=2000 Width=2000
Height=6883 Height=6939
MaxLeft=-1 MaxLeft=-1
MaxTop=-1 MaxTop=-1
ClientWidth=2000 ClientWidth=2000
ClientHeight=6883 ClientHeight=6939
TBDockHeight=4888 TBDockHeight=4888
LRDockWidth=5305 LRDockWidth=5305
Dockable=1 Dockable=1
@ -696,14 +695,14 @@ Visible=0
Docked=1 Docked=1
State=0 State=0
Left=0 Left=0
Top=18 Top=0
Width=3820 Width=3820
Height=1401 Height=1424
MaxLeft=-1 MaxLeft=-1
MaxTop=-1 MaxTop=-1
ClientWidth=3820 ClientWidth=3820
ClientHeight=1401 ClientHeight=1424
TBDockHeight=1401 TBDockHeight=1424
LRDockWidth=3820 LRDockWidth=3820
Dockable=1 Dockable=1
StayOnTop=0 StayOnTop=0
@ -727,7 +726,7 @@ MaxLeft=-1
MaxTop=-1 MaxTop=-1
ClientWidth=2000 ClientWidth=2000
ClientHeight=4585 ClientHeight=4585
TBDockHeight=7164 TBDockHeight=7220
LRDockWidth=2000 LRDockWidth=2000
Dockable=1 Dockable=1
StayOnTop=0 StayOnTop=0
@ -736,22 +735,22 @@ ActiveTabID=ProjectManager
TabDockClients=ProjectManager,ModelViewTool,DataExplorerContainer,frmDesignPreview,TFileExplorerForm TabDockClients=ProjectManager,ModelViewTool,DataExplorerContainer,frmDesignPreview,TFileExplorerForm
[DockSite3] [DockSite3]
HostDockSite=DockLeftPanel HostDockSite=LeftDockTabSet
DockSiteType=1 DockSiteType=1
PercentageSizes=1 PercentageSizes=1
Create=1 Create=1
Visible=1 Visible=0
Docked=1 Docked=1
State=0 State=0
Left=0 Left=0
Top=18 Top=18
Width=1898 Width=1898
Height=3554 Height=7545
MaxLeft=-1 MaxLeft=-1
MaxTop=-1 MaxTop=-1
ClientWidth=1898 ClientWidth=1898
ClientHeight=3554 ClientHeight=7545
TBDockHeight=7164 TBDockHeight=7220
LRDockWidth=1898 LRDockWidth=1898
Dockable=1 Dockable=1
StayOnTop=0 StayOnTop=0
@ -770,12 +769,12 @@ State=0
Left=0 Left=0
Top=449 Top=449
Width=2000 Width=2000
Height=2713 Height=4383
MaxLeft=-1 MaxLeft=-1
MaxTop=-1 MaxTop=-1
ClientWidth=2000 ClientWidth=2000
ClientHeight=2713 ClientHeight=4383
TBDockHeight=7164 TBDockHeight=7220
LRDockWidth=2000 LRDockWidth=2000
Dockable=1 Dockable=1
StayOnTop=0 StayOnTop=0

View File

@ -1,9 +1,9 @@
[Stats] [Stats]
EditorSecs=5087 EditorSecs=6251
DesignerSecs=331 DesignerSecs=331
InspectorSecs=170 InspectorSecs=170
CompileSecs=499205 CompileSecs=540648
OtherSecs=1302 OtherSecs=1366
StartTime=22/01/2017 14:51:01 StartTime=22/01/2017 14:51:01
RealKeys=0 RealKeys=0
EffectiveKeys=0 EffectiveKeys=0

View File

@ -61,6 +61,7 @@ type
procedure FormShow(Sender: TObject); procedure FormShow(Sender: TObject);
procedure ChromiumWindow1AfterCreated(Sender: TObject); procedure ChromiumWindow1AfterCreated(Sender: TObject);
private 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; procedure WMMove(var aMessage : TWMMove); message WM_MOVE;
procedure WMMoving(var aMessage : TMessage); message WM_MOVING; procedure WMMoving(var aMessage : TMessage); message WM_MOVING;
public public
@ -74,20 +75,37 @@ implementation
{$R *.dfm} {$R *.dfm}
procedure TForm1.GoBtnClick(Sender: TObject); // This is a demo with the simplest web browser you can build using CEF4Delphi and
// it doesn't show any sign of progress like other web browsers do.
// Remember that it may take a few seconds to load if Windows update, your antivirus or
// any other windows service is using your hard drive.
// Depending on your internet connection it may take longer than expected.
// 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.
procedure TForm1.FormShow(Sender: TObject);
begin begin
ChromiumWindow1.LoadURL(AddressEdt.Text); // 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;
end; 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.
AddressPnl.Enabled := True; AddressPnl.Enabled := True;
GoBtn.Click; GoBtn.Click;
end; end;
procedure TForm1.FormShow(Sender: TObject); procedure TForm1.GoBtnClick(Sender: TObject);
begin begin
ChromiumWindow1.CreateBrowser; // This will load the URL in the edit box
ChromiumWindow1.LoadURL(AddressEdt.Text);
end; end;
procedure TForm1.WMMove(var aMessage : TWMMove); procedure TForm1.WMMove(var aMessage : TWMMove);