diff --git a/demos/SimpleBrowser/SimpleBrowser.dpr b/demos/SimpleBrowser/SimpleBrowser.dpr index 413d4568..f13b410a 100644 --- a/demos/SimpleBrowser/SimpleBrowser.dpr +++ b/demos/SimpleBrowser/SimpleBrowser.dpr @@ -51,12 +51,14 @@ 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} begin GlobalCEFApp := TCefApplication.Create; // 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.ResourcesDirPath := 'cef'; @@ -66,6 +68,9 @@ begin 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 begin Application.Initialize; diff --git a/demos/SimpleBrowser/SimpleBrowser.dsk b/demos/SimpleBrowser/SimpleBrowser.dsk index bb1f6a7f..eba9f64c 100644 --- a/demos/SimpleBrowser/SimpleBrowser.dsk +++ b/demos/SimpleBrowser/SimpleBrowser.dsk @@ -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,, [Modules] -Module0=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\SimpleBrowser\SimpleBrowser.dproj -Module1=default.htm -Module2=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\SimpleBrowser\uSimpleBrowser.pas +Module0=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\SimpleBrowser\uSimpleBrowser.pas +Module1=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\SimpleBrowser\SimpleBrowser.dproj +Module2=default.htm Count=3 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] ModuleType=TBaseProject [default.htm] ModuleType=TURLModule -[C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\SimpleBrowser\uSimpleBrowser.pas] -ModuleType=TSourceModule - [EditWindow0] 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 View1=1 View2=2 @@ -48,18 +48,17 @@ ClientHeight=9417 DockedToMainForm=1 BorlandEditorCodeExplorer=BorlandEditorCodeExplorer@EditWindow0 TopPanelSize=0 -LeftPanelSize=1898 -LeftPanelClients=PropertyInspector,DockSite3 -LeftPanelData=000008000101000000001615000000000000016A0700000000000001000000005D0E000009000000446F636B53697465330100000000471D00001100000050726F7065727479496E73706563746F72FFFFFFFF +LeftPanelSize=0 RightPanelSize=2000 RightPanelClients=DockSite2,DockSite4 -RightPanelData=00000800010100000000161500000000000001D00700000000000001000000004312000009000000446F636B53697465320100000000471D000009000000446F636B5369746534FFFFFFFF -BottomPanelSize=1551 +RightPanelData=00000800010100000000A21900000000000001D00700000000000001000000004312000009000000446F636B536974653201000000009723000009000000446F636B5369746534FFFFFFFF +BottomPanelSize=0 BottomPanelClients=DockSite1,MessageView -BottomPanelData=0000080001020100000009000000446F636B53697465313B36000000000000020F0600000000000001000000003B3600000F0000004D65737361676556696577466F726DFFFFFFFF +BottomPanelData=0000080001020200000009000000446F636B53697465310F0000004D65737361676556696577466F726D3B36000000000000020F0600000000000001000000003B3600000F0000004D65737361676556696577466F726DFFFFFFFF BottomMiddlePanelSize=0 BottomMiddlePanelClients=DockSite0,GraphDrawingModel BottomMiddelPanelData=0000080001020200000009000000446F636B536974653010000000477261706844726177696E67566965779D1D00000000000002F306000000000000FFFFFFFF +TabDockLeftClients=PropertyInspector=0,DockSite3=1 [View0] CustomEditViewType=TWelcomePageView @@ -68,8 +67,8 @@ WelcomePageURL=bds:/default.htm [View1] CustomEditViewType=TEditView Module=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\SimpleBrowser\SimpleBrowser.dpr -CursorX=2 -CursorY=60 +CursorX=63 +CursorY=72 TopLine=37 LeftCol=1 Elisions= @@ -79,9 +78,9 @@ EditViewName=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\d [View2] CustomEditViewType=TEditView Module=C:\Users\usuario\Documents\Embarcadero\Studio\Projects\CEF4Delphi\demos\SimpleBrowser\uSimpleBrowser.pas -CursorX=66 -CursorY=70 -TopLine=44 +CursorX=97 +CursorY=57 +TopLine=42 LeftCol=1 Elisions= Bookmarks= @@ -104,11 +103,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1121 +Height=1143 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1121 +ClientHeight=1143 TBDockHeight=213 LRDockWidth=13602 Dockable=1 @@ -165,7 +164,7 @@ StayOnTop=0 [MessageView] PercentageSizes=1 Create=1 -Visible=1 +Visible=0 Docked=1 State=0 Left=0 @@ -190,11 +189,11 @@ State=0 Left=0 Top=0 Width=2000 -Height=2713 +Height=4383 MaxLeft=-1 MaxTop=-1 ClientWidth=2000 -ClientHeight=2713 +ClientHeight=4383 TBDockHeight=7152 LRDockWidth=2000 Dockable=1 @@ -244,8 +243,8 @@ Create=1 Visible=0 Docked=1 State=0 -Left=-121 -Top=-70 +Left=-148 +Top=-132 Width=1844 Height=3139 MaxLeft=-1 @@ -298,7 +297,7 @@ StayOnTop=0 [PropertyInspector] PercentageSizes=1 Create=1 -Visible=1 +Visible=0 Docked=1 State=0 Left=0 @@ -309,7 +308,7 @@ MaxLeft=-1 MaxTop=-1 ClientWidth=1898 ClientHeight=3744 -TBDockHeight=7164 +TBDockHeight=7220 LRDockWidth=1898 Dockable=1 StayOnTop=0 @@ -324,11 +323,11 @@ State=0 Left=0 Top=0 Width=2000 -Height=6883 +Height=6939 MaxLeft=-1 MaxTop=-1 ClientWidth=2000 -ClientHeight=6883 +ClientHeight=6939 TBDockHeight=5964 LRDockWidth=2508 Dockable=1 @@ -340,8 +339,8 @@ Create=1 Visible=0 Docked=1 State=0 -Left=-946 -Top=5 +Left=-898 +Top=-132 Width=2844 Height=6200 MaxLeft=-1 @@ -359,8 +358,8 @@ Create=1 Visible=0 Docked=1 State=0 -Left=-1152 -Top=247 +Left=-1026 +Top=-132 Width=273 Height=359 MaxLeft=-1 @@ -384,11 +383,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1121 +Height=1143 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1121 +ClientHeight=1143 TBDockHeight=415 LRDockWidth=4953 Dockable=1 @@ -403,11 +402,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1121 +Height=1143 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1121 +ClientHeight=1143 TBDockHeight=213 LRDockWidth=7406 Dockable=1 @@ -426,11 +425,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1121 +Height=1143 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1121 +ClientHeight=1143 TBDockHeight=1536 LRDockWidth=3484 Dockable=1 @@ -445,11 +444,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1121 +Height=1143 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1121 +ClientHeight=1143 TBDockHeight=2063 LRDockWidth=3484 Dockable=1 @@ -483,11 +482,11 @@ State=0 Left=0 Top=0 Width=2336 -Height=964 +Height=1200 MaxLeft=-1 MaxTop=-1 ClientWidth=2336 -ClientHeight=964 +ClientHeight=1200 TBDockHeight=2321 LRDockWidth=2820 Dockable=1 @@ -548,11 +547,11 @@ State=0 Left=0 Top=0 Width=2000 -Height=6883 +Height=6939 MaxLeft=-1 MaxTop=-1 ClientWidth=2000 -ClientHeight=6883 +ClientHeight=6939 TBDockHeight=4888 LRDockWidth=7148 Dockable=1 @@ -564,8 +563,8 @@ Create=1 Visible=0 Docked=1 State=0 -Left=249 -Top=709 +Left=0 +Top=0 Width=2859 Height=3206 MaxLeft=-1 @@ -586,11 +585,11 @@ State=0 Left=0 Top=0 Width=3820 -Height=1121 +Height=1143 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1121 +ClientHeight=1143 TBDockHeight=1547 LRDockWidth=8742 Dockable=1 @@ -612,11 +611,11 @@ State=0 Left=0 Top=0 Width=1898 -Height=3554 +Height=7545 MaxLeft=-1 MaxTop=-1 ClientWidth=1898 -ClientHeight=3554 +ClientHeight=7545 TBDockHeight=3677 LRDockWidth=1898 Dockable=1 @@ -631,11 +630,11 @@ State=0 Left=0 Top=0 Width=2000 -Height=6883 +Height=6939 MaxLeft=-1 MaxTop=-1 ClientWidth=2000 -ClientHeight=6883 +ClientHeight=6939 TBDockHeight=4888 LRDockWidth=5305 Dockable=1 @@ -696,14 +695,14 @@ Visible=0 Docked=1 State=0 Left=0 -Top=18 +Top=0 Width=3820 -Height=1401 +Height=1424 MaxLeft=-1 MaxTop=-1 ClientWidth=3820 -ClientHeight=1401 -TBDockHeight=1401 +ClientHeight=1424 +TBDockHeight=1424 LRDockWidth=3820 Dockable=1 StayOnTop=0 @@ -727,7 +726,7 @@ MaxLeft=-1 MaxTop=-1 ClientWidth=2000 ClientHeight=4585 -TBDockHeight=7164 +TBDockHeight=7220 LRDockWidth=2000 Dockable=1 StayOnTop=0 @@ -736,22 +735,22 @@ ActiveTabID=ProjectManager TabDockClients=ProjectManager,ModelViewTool,DataExplorerContainer,frmDesignPreview,TFileExplorerForm [DockSite3] -HostDockSite=DockLeftPanel +HostDockSite=LeftDockTabSet DockSiteType=1 PercentageSizes=1 Create=1 -Visible=1 +Visible=0 Docked=1 State=0 Left=0 Top=18 Width=1898 -Height=3554 +Height=7545 MaxLeft=-1 MaxTop=-1 ClientWidth=1898 -ClientHeight=3554 -TBDockHeight=7164 +ClientHeight=7545 +TBDockHeight=7220 LRDockWidth=1898 Dockable=1 StayOnTop=0 @@ -770,12 +769,12 @@ State=0 Left=0 Top=449 Width=2000 -Height=2713 +Height=4383 MaxLeft=-1 MaxTop=-1 ClientWidth=2000 -ClientHeight=2713 -TBDockHeight=7164 +ClientHeight=4383 +TBDockHeight=7220 LRDockWidth=2000 Dockable=1 StayOnTop=0 diff --git a/demos/SimpleBrowser/SimpleBrowser.res b/demos/SimpleBrowser/SimpleBrowser.res index 0f72ec13..4ebd2d59 100644 Binary files a/demos/SimpleBrowser/SimpleBrowser.res and b/demos/SimpleBrowser/SimpleBrowser.res differ diff --git a/demos/SimpleBrowser/SimpleBrowser.stat b/demos/SimpleBrowser/SimpleBrowser.stat index cf60a66d..64f28678 100644 --- a/demos/SimpleBrowser/SimpleBrowser.stat +++ b/demos/SimpleBrowser/SimpleBrowser.stat @@ -1,9 +1,9 @@ [Stats] -EditorSecs=5087 +EditorSecs=6251 DesignerSecs=331 InspectorSecs=170 -CompileSecs=499205 -OtherSecs=1302 +CompileSecs=540648 +OtherSecs=1366 StartTime=22/01/2017 14:51:01 RealKeys=0 EffectiveKeys=0 diff --git a/demos/SimpleBrowser/uSimpleBrowser.pas b/demos/SimpleBrowser/uSimpleBrowser.pas index 246e203c..061ba175 100644 --- a/demos/SimpleBrowser/uSimpleBrowser.pas +++ b/demos/SimpleBrowser/uSimpleBrowser.pas @@ -61,6 +61,7 @@ type procedure FormShow(Sender: TObject); procedure ChromiumWindow1AfterCreated(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; procedure WMMoving(var aMessage : TMessage); message WM_MOVING; public @@ -74,20 +75,37 @@ implementation {$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 - 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; procedure TForm1.ChromiumWindow1AfterCreated(Sender: TObject); begin + // Now the browser is fully initialized we can load the initial web page. AddressPnl.Enabled := True; GoBtn.Click; end; -procedure TForm1.FormShow(Sender: TObject); +procedure TForm1.GoBtnClick(Sender: TObject); begin - ChromiumWindow1.CreateBrowser; + // This will load the URL in the edit box + ChromiumWindow1.LoadURL(AddressEdt.Text); end; procedure TForm1.WMMove(var aMessage : TWMMove);