mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2025-05-23 21:50:21 +02:00
The SubProcess demo now uses an external unit to create and destroy GlobalCEFApp
This commit is contained in:
parent
bf402109bf
commit
09161b19e1
@ -46,51 +46,28 @@ uses
|
||||
{$ELSE}
|
||||
Forms,
|
||||
Windows,
|
||||
{$ENDIF}
|
||||
{$ENDIF }
|
||||
uCEFApplication,
|
||||
uSimpleBrowser in 'uSimpleBrowser.pas' {Form1};
|
||||
uSimpleBrowser in 'uSimpleBrowser.pas' {Form1},
|
||||
uCEFLoader in 'uCEFLoader.pas';
|
||||
|
||||
{$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.
|
||||
// The IMAGE_FILE_LARGE_ADDRESS_AWARE constant is declared in WinApi.Windows. If you don't want to add
|
||||
// WinApi.Windows to the 'uses' section in this file just replace the following line by
|
||||
// {$SetPEFlags $20}
|
||||
{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE}
|
||||
|
||||
begin
|
||||
GlobalCEFApp := TCefApplication.Create;
|
||||
// This demo has the GlobalCEFApp creation, initialization and destruction in uCEFLoader.pas
|
||||
// Read the code comments in uCEFLoader.pas for more details.
|
||||
|
||||
// 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';
|
||||
GlobalCEFApp.LocalesDirPath := 'cef\locales';
|
||||
GlobalCEFApp.cache := 'cef\cache';
|
||||
GlobalCEFApp.cookies := 'cef\cookies';
|
||||
GlobalCEFApp.UserDataPath := 'cef\User Data';
|
||||
}
|
||||
|
||||
GlobalCEFApp.BrowserSubprocessPath := 'SubProcess.exe';
|
||||
|
||||
// Follow these steps to test this demo :
|
||||
// 1. Build the SubProcess project in this directory.
|
||||
// 2. Copy the CEF binaries to the BIN directory in CEF4Delphi.
|
||||
// 3. Build this project : SimpleBrowser
|
||||
// 4. Run this demo : SimpleBrowser
|
||||
|
||||
// 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;
|
||||
{$IFDEF DELPHI11_UP}
|
||||
Application.MainFormOnTaskbar := True;
|
||||
{$ENDIF}
|
||||
Application.CreateForm(TForm1, Form1);
|
||||
Application.Run;
|
||||
end;
|
||||
|
||||
GlobalCEFApp.Free;
|
||||
GlobalCEFApp := nil;
|
||||
Application.Initialize;
|
||||
{$IFDEF DELPHI11_UP}
|
||||
Application.MainFormOnTaskbar := True;
|
||||
{$ENDIF}
|
||||
Application.CreateForm(TForm1, Form1);
|
||||
Application.Run;
|
||||
end.
|
||||
|
@ -134,6 +134,7 @@
|
||||
<DCCReference Include="uSimpleBrowser.pas">
|
||||
<Form>Form1</Form>
|
||||
</DCCReference>
|
||||
<DCCReference Include="uCEFLoader.pas"/>
|
||||
<BuildConfiguration Include="Release">
|
||||
<Key>Cfg_2</Key>
|
||||
<CfgParent>Base</CfgParent>
|
||||
@ -162,6 +163,12 @@
|
||||
</Delphi.Personality>
|
||||
<Deployment Version="3">
|
||||
<DeployFile LocalName="Win32\Debug\SimpleBrowser.exe" Configuration="Debug" Class="ProjectOutput"/>
|
||||
<DeployFile LocalName="..\..\bin\SimpleBrowser.exe" Configuration="Debug" Class="ProjectOutput">
|
||||
<Platform Name="Win32">
|
||||
<RemoteName>SimpleBrowser.exe</RemoteName>
|
||||
<Overwrite>true</Overwrite>
|
||||
</Platform>
|
||||
</DeployFile>
|
||||
<DeployClass Name="AdditionalDebugSymbols">
|
||||
<Platform Name="iOSSimulator">
|
||||
<Operation>1</Operation>
|
||||
|
84
demos/SubProcess/uCEFLoader.pas
Normal file
84
demos/SubProcess/uCEFLoader.pas
Normal file
@ -0,0 +1,84 @@
|
||||
// ************************************************************************
|
||||
// ***************************** CEF4Delphi *******************************
|
||||
// ************************************************************************
|
||||
//
|
||||
// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based
|
||||
// browser in Delphi applications.
|
||||
//
|
||||
// The original license of DCEF3 still applies to CEF4Delphi.
|
||||
//
|
||||
// For more information about CEF4Delphi visit :
|
||||
// https://www.briskbard.com/index.php?lang=en&pageid=cef
|
||||
//
|
||||
// Copyright © 2018 Salvador Diaz Fau. All rights reserved.
|
||||
//
|
||||
// ************************************************************************
|
||||
// ************ vvvv Original license and comments below vvvv *************
|
||||
// ************************************************************************
|
||||
(*
|
||||
* Delphi Chromium Embedded 3
|
||||
*
|
||||
* Usage allowed under the restrictions of the Lesser GNU General Public License
|
||||
* or alternatively the restrictions of the Mozilla Public License 1.1
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
||||
* the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* Unit owner : Henri Gourvest <hgourvest@gmail.com>
|
||||
* Web site : http://www.progdigy.com
|
||||
* Repository : http://code.google.com/p/delphichromiumembedded/
|
||||
* Group : http://groups.google.com/group/delphichromiumembedded
|
||||
*
|
||||
* Embarcadero Technologies, Inc is not permitted to use or redistribute
|
||||
* this source code without explicit permission.
|
||||
*
|
||||
*)
|
||||
|
||||
unit uCEFLoader;
|
||||
|
||||
interface
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
uCEFApplication;
|
||||
|
||||
// Follow these steps to test this demo :
|
||||
// 1. Build the SubProcess project in this directory.
|
||||
// 2. Copy the CEF binaries to the BIN directory in CEF4Delphi.
|
||||
// 3. Build this project : SimpleBrowser
|
||||
// 4. Run this demo : SimpleBrowser
|
||||
|
||||
procedure CreateGlobalCEFApp;
|
||||
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.
|
||||
// The cache, cookies and user data directories must be writable.
|
||||
{
|
||||
GlobalCEFApp.FrameworkDirPath := 'cef';
|
||||
GlobalCEFApp.ResourcesDirPath := 'cef';
|
||||
GlobalCEFApp.LocalesDirPath := 'cef\locales';
|
||||
GlobalCEFApp.cache := 'cef\cache';
|
||||
GlobalCEFApp.cookies := 'cef\cookies';
|
||||
GlobalCEFApp.UserDataPath := 'cef\User Data';
|
||||
}
|
||||
|
||||
GlobalCEFApp.BrowserSubprocessPath := 'SubProcess.exe';
|
||||
|
||||
// This demo uses a different EXE for the subprocesses.
|
||||
// With this configuration it's not necessary to have the
|
||||
// GlobalCEFApp.StartMainProcess call in a if..then clause.
|
||||
|
||||
GlobalCEFApp.StartMainProcess;
|
||||
end;
|
||||
|
||||
initialization
|
||||
CreateGlobalCEFApp;
|
||||
|
||||
finalization
|
||||
DestroyGlobalCEFApp;
|
||||
|
||||
end.
|
Loading…
x
Reference in New Issue
Block a user