mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2025-06-02 21:57:37 +02:00
Enable Chrome runtime in MobileBrowser demo
This commit is contained in:
parent
16f76f39aa
commit
496db82294
@ -8,30 +8,20 @@ uses
|
|||||||
{$ELSE}
|
{$ELSE}
|
||||||
Forms,
|
Forms,
|
||||||
{$ENDIF }
|
{$ENDIF }
|
||||||
uCEFApplication, uCEFConstants,
|
uCEFApplication,
|
||||||
uMobileBrowser in 'uMobileBrowser.pas' {Form1};
|
uMobileBrowser in 'uMobileBrowser.pas' {Form1};
|
||||||
|
|
||||||
{$R *.res}
|
{$R *.res}
|
||||||
|
|
||||||
|
{$IFDEF WIN32}
|
||||||
const
|
const
|
||||||
IMAGE_FILE_LARGE_ADDRESS_AWARE = $0020;
|
IMAGE_FILE_LARGE_ADDRESS_AWARE = $0020;
|
||||||
|
// CEF needs to set the LARGEADDRESSAWARE ($20) flag which allows 32-bit processes to use up to 3GB of RAM.
|
||||||
// CEF needs to set the LARGEADDRESSAWARE ($20) flag which allows 32-bit processes to use up to 3GB of RAM.
|
{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE}
|
||||||
{$IFDEF WIN32}{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE}{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
begin
|
begin
|
||||||
GlobalCEFApp := TCefApplication.Create;
|
CreateGlobalCEFApp;
|
||||||
|
|
||||||
// In case you want to use custom directories for the CEF3 binaries, cache and user data.
|
|
||||||
// If you don't set a cache directory the browser will use in-memory cache.
|
|
||||||
{
|
|
||||||
GlobalCEFApp.FrameworkDirPath := 'c:\cef';
|
|
||||||
GlobalCEFApp.ResourcesDirPath := 'c:\cef';
|
|
||||||
GlobalCEFApp.LocalesDirPath := 'c:\cef\locales';
|
|
||||||
GlobalCEFApp.EnableGPU := True; // Enable hardware acceleration
|
|
||||||
GlobalCEFApp.cache := 'c:\cef\cache';
|
|
||||||
GlobalCEFApp.UserDataPath := 'c:\cef\User Data';
|
|
||||||
}
|
|
||||||
|
|
||||||
// You *MUST* call GlobalCEFApp.StartMainProcess in a if..then clause
|
// You *MUST* call GlobalCEFApp.StartMainProcess in a if..then clause
|
||||||
// with the Application initialization inside the begin..end.
|
// with the Application initialization inside the begin..end.
|
||||||
@ -46,6 +36,5 @@ begin
|
|||||||
Application.Run;
|
Application.Run;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
GlobalCEFApp.Free;
|
DestroyGlobalCEFApp;
|
||||||
GlobalCEFApp := nil;
|
|
||||||
end.
|
end.
|
||||||
|
@ -97,6 +97,8 @@ type
|
|||||||
var
|
var
|
||||||
Form1: TForm1;
|
Form1: TForm1;
|
||||||
|
|
||||||
|
procedure CreateGlobalCEFApp;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
{$R *.dfm}
|
{$R *.dfm}
|
||||||
@ -122,6 +124,19 @@ const
|
|||||||
DEVTOOLS_CLEARDEVICEMETRICSOVERRIDE_MSGID = 4;
|
DEVTOOLS_CLEARDEVICEMETRICSOVERRIDE_MSGID = 4;
|
||||||
DEVTOOLS_SETDEVICEMETRICSOVERRIDE_MSGID = 5;
|
DEVTOOLS_SETDEVICEMETRICSOVERRIDE_MSGID = 5;
|
||||||
|
|
||||||
|
procedure CreateGlobalCEFApp;
|
||||||
|
begin
|
||||||
|
GlobalCEFApp := TCefApplication.Create;
|
||||||
|
GlobalCEFApp.cache := 'cache';
|
||||||
|
GlobalCEFApp.EnablePrintPreview := True;
|
||||||
|
GlobalCEFApp.EnableGPU := True;
|
||||||
|
GlobalCEFApp.ChromeRuntime := True;
|
||||||
|
{$IFDEF DEBUG}
|
||||||
|
GlobalCEFApp.LogFile := 'debug.log';
|
||||||
|
GlobalCEFApp.LogSeverity := LOGSEVERITY_INFO;
|
||||||
|
{$ENDIF}
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
||||||
begin
|
begin
|
||||||
CanClose := FCanClose;
|
CanClose := FCanClose;
|
||||||
@ -131,6 +146,10 @@ begin
|
|||||||
FClosing := True;
|
FClosing := True;
|
||||||
Visible := False;
|
Visible := False;
|
||||||
Chromium1.CloseBrowser(True);
|
Chromium1.CloseBrowser(True);
|
||||||
|
|
||||||
|
// Workaround for the missing TChormium.OnClose event when "Chrome runtime" is enabled.
|
||||||
|
if GlobalCEFApp.ChromeRuntime then
|
||||||
|
CEFWindowParent1.Free;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user