CEF3 JavaScript extensions

335 views
Skip to first unread message

jg91000

unread,
Jul 22, 2015, 4:07:16 AM7/22/15
to delphichromiumembedded
Hi everyone,

I'm modifying the guiclient demo sample (CEF3) in order to call a Delphi 2010 procedure from javascript code.
I 'm using CefSingleProcess := False;
My extension is correctly called, then i use the following code to send a value to main process, but the call to SendProcessMessage never returns back and the Renderer brings an Access Violation.

class function TTestExtension.hello: string;
begin
  Result := 'Hello from Delphi';
end;

class procedure TTestExtension.Test22 (s:string);
var
    msg: ICefProcessMessage;
    rc: boolean ;
begin
    msg := TCefProcessMessageRef.New('MsgName');
    msg.ArgumentList.SetString(0, 'Parameter-0');

    ShowMessage('here ok') ;
    rc := MainForm.crm.browser.SendProcessMessage(PID_BROWSER, msg) ;
    ShowMessage ('rc:' + BooltoStr(rc));

end;

So my question is :
What is the best way to send a message to the main process ?

Thanks in advance

Regards

marchomal mal

unread,
Jul 24, 2015, 1:26:26 PM7/24/15
to delphichromiumembedded, jorge.g...@gmail.com
Hi,

I don´t know if it's the better way to do that.
But this works for me.

In main app, execute "ExecuteJavascript" function, and after that, 
I send a message to the process with the PID_RENDERER pid.

In the "Rendered" process then I capture the message and send back an other message
to de main process, the process with the PID_BROWSER pid.

Then capture the final message in the main process.

Excuse my english.
Best regards
Unit1.pas
Project2.dpr
test.html

jg91000

unread,
Jul 28, 2015, 3:46:53 AM7/28/15
to delphichromiumembedded, jorge.g...@gmail.com
Hi :

 Thanks for your answer.

In my case in the renderer process i get the browser Object in the OnBrowserCreated, and use it later, it works.
That way i have a nasynchronous way of communication.

Best regards
Reply all
Reply to author
Forward
0 new messages