1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-06-12 22:07:39 +02:00
This commit is contained in:
Salvador Díaz Fau
2017-11-25 19:04:15 +01:00
parent b54a2861c4
commit f5f1a767c9
47 changed files with 1114 additions and 851 deletions

View File

@ -41,18 +41,13 @@ program JSWindowBindingWithFunction;
uses
{$IFDEF DELPHI16_UP}
WinApi.Windows,
Vcl.Forms,
System.SysUtils,
WinApi.Windows,
{$ELSE}
Forms,
Windows,
SysUtils,
{$ENDIF }
uCEFApplication,
uCEFInterfaces,
uCEFv8Value,
uCEFConstants,
uJSWindowBindingWithFunction in 'uJSWindowBindingWithFunction.pas' {JSWindowBindingWithFunctionFrm},
uMyV8Handler in 'uMyV8Handler.pas';
@ -61,18 +56,6 @@ uses
// CEF3 needs to set the LARGEADDRESSAWARE flag which allows 32-bit processes to use up to 3GB of RAM.
{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE}
procedure GlobalCEFApp_OnContextCreated(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context);
var
TempHandler : ICefv8Handler;
begin
// This is the JS Window Binding example with a function in the "JavaScript Integration" wiki page at
// https://bitbucket.org/chromiumembedded/cef/wiki/JavaScriptIntegration.md
TempHandler := TMyV8Handler.Create;
context.Global.SetValueByKey('myfunc', TCefv8ValueRef.NewFunction('myfunc', TempHandler), V8_PROPERTY_ATTRIBUTE_NONE);
end;
begin
GlobalCEFApp := TCefApplication.Create;
GlobalCEFApp.OnContextCreated := GlobalCEFApp_OnContextCreated;

View File

@ -100,6 +100,7 @@
<PropertyGroup Condition="'$(Cfg_2_Win32)'!=''">
<AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
<AppEnableHighDPI>true</AppEnableHighDPI>
<BT_BuildType>Debug</BT_BuildType>
</PropertyGroup>
<ItemGroup>
<DelphiCompile Include="$(MainSource)">

View File

@ -74,16 +74,35 @@ type
var
JSWindowBindingWithFunctionFrm: TJSWindowBindingWithFunctionFrm;
procedure GlobalCEFApp_OnContextCreated(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context);
implementation
{$R *.dfm}
uses
uCEFv8Value, uMyV8Handler;
// The CEF3 document describing JavaScript integration is here :
// https://bitbucket.org/chromiumembedded/cef/wiki/JavaScriptIntegration.md
// The HTML file in this demo has a button that shows the result of 'window.myfunc()'
// which was set in the GlobalCEFApp.OnContextCreated event.
procedure GlobalCEFApp_OnContextCreated(const browser: ICefBrowser; const frame: ICefFrame; const context: ICefv8Context);
var
TempHandler : ICefv8Handler;
TempFunction : ICefv8Value;
begin
// This is the JS Window Binding example with a function in the "JavaScript Integration" wiki page at
// https://bitbucket.org/chromiumembedded/cef/wiki/JavaScriptIntegration.md
TempHandler := TMyV8Handler.Create;
TempFunction := TCefv8ValueRef.NewFunction('myfunc', TempHandler);
context.Global.SetValueByKey('myfunc', TempFunction, V8_PROPERTY_ATTRIBUTE_NONE);
end;
procedure TJSWindowBindingWithFunctionFrm.GoBtnClick(Sender: TObject);
begin
Chromium1.LoadURL(Edit1.Text);