1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-06-12 22:07:39 +02:00

The JSExtensionWithFunction demo now sends a text message back to the main process

This commit is contained in:
Salvador Díaz Fau
2018-03-21 11:21:41 +01:00
parent 7242c181a4
commit 665957e132
3 changed files with 42 additions and 2 deletions

View File

@ -59,6 +59,7 @@ type
CEFWindowParent1: TCEFWindowParent;
Chromium1: TChromium;
Timer1: TTimer;
StatusBar1: TStatusBar;
procedure FormShow(Sender: TObject);
procedure GoBtnClick(Sender: TObject);
procedure Chromium1AfterCreated(Sender: TObject; const browser: ICefBrowser);
@ -70,6 +71,9 @@ type
var popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo;
var client: ICefClient; var settings: TCefBrowserSettings;
var noJavascriptAccess: Boolean; out Result: Boolean);
procedure Chromium1ProcessMessageReceived(Sender: TObject;
const browser: ICefBrowser; sourceProcess: TCefProcessId;
const message: ICefProcessMessage; out Result: Boolean);
protected
procedure BrowserCreatedMsg(var aMessage : TMessage); message CEF_AFTERCREATED;
procedure WMMove(var aMessage : TWMMove); message WM_MOVE;
@ -143,6 +147,18 @@ begin
Result := (targetDisposition in [WOD_NEW_FOREGROUND_TAB, WOD_NEW_BACKGROUND_TAB, WOD_NEW_POPUP, WOD_NEW_WINDOW]);
end;
procedure TJSExtensionWithFunctionFrm.Chromium1ProcessMessageReceived(
Sender: TObject; const browser: ICefBrowser;
sourceProcess: TCefProcessId; const message: ICefProcessMessage;
out Result: Boolean);
begin
if (message.Name = TEST_MESSAGE_NAME) then
begin
StatusBar1.Panels[0].Text := DateTimeToStr(now) + ' - ' + message.ArgumentList.GetString(0); // this doesn't create/destroy components
Result := True;
end
end;
procedure TJSExtensionWithFunctionFrm.FormShow(Sender: TObject);
begin
// GlobalCEFApp.GlobalContextInitialized has to be TRUE before creating any browser