Page 2 of 3
Re: Retrun JS result Tchromium
Posted: Thu Sep 12, 2024 8:36 am
by subin
Thanks a lot for your reply.
Please let me know when the event OnWebKitInitialized is triggered.
Thanks
Re: Retrun JS result Tchromium
Posted: Thu Sep 12, 2024 10:35 am
by salvadordf
As you can see in the documentation, that event is executed in the render process.
Read this to know how to debug code in multiple processes :
https://www.briskbard.com/index.php?lang=en&pageid=cef#debugging
Re: Retrun JS result Tchromium
Posted: Thu Sep 12, 2024 12:43 pm
by subin
Thanks for your reply.
In the JS example, CreateGlobalCEFApp; is called in the program file.
In my case I am using a dll (run time package) and need to know where to call CreateGlobalCEFApp.
I tried to call this with in a class of the package. However if gives exception when accessing it for the second time (GlobalCEFApp.StartMainProcess; is called again). Please help
Re: Retrun JS result Tchromium
Posted: Thu Sep 12, 2024 12:49 pm
by salvadordf
CEF can only be initialized once per process.
Export 2 functions to initialize and finalize GlobalCEFApp. See the DLLBrowser demo.
Re: Retrun JS result Tchromium
Posted: Fri Sep 13, 2024 6:27 am
by subin
Thanks for your reply.
IN my application I am using dll( runtime package). I created GlobalCEFApp in initialization section of a unit file of the library. Also called GlobalCEFApp.StartMainProcess; (without insde if statement) after creation of GlobalCEFApp. In finalization called DestroyGlobalCEFApp. However the code
TempJSCode := 'var testhtml = document.getElementById(' + quotedstr('ctl00_processingRequestPanel') +
'.innerHTML; ' + 'myextension.sendresulttobrowser(testhtml, ' + quotedstr(HTMLDOMELEMENT_MESSAGE_NAME) + ');';
fBrowser.ExecuteJavaScript(TempJSCode, 'about:blank', 0);
is not executing and the onprocessmessagerecived event is not invoking. Could you please help.
Thank you
Re: Retrun JS result Tchromium
Posted: Fri Sep 13, 2024 9:09 am
by salvadordf
https://github.com/salvadordf/CEF4Delphi/blob/66279dde4269ac4360d3475d1dd55fd56cc77c89/demos/Delphi_VCL/DLLBrowser/DLLBrowser.dpr#L31
Code: Select all
// CEF3 needs to be initialized and finalized outside the DLL's initialization and
// finalization sections. For this reason, you need to call InitializeCEF4Delphi
// after you load this DLL and you also need to call FinalizeCEF4Delphi before
// unloading this DLL.
Re: Retrun JS result Tchromium
Posted: Mon Sep 23, 2024 4:56 am
by subin
Thanks for your reply.
I am using a runtime dll.
When I call procedure InitializeCEF4Delphi; stdcall; external 'XX.dll';, If fails to load the runtime dll when opening the IDE.
Re: Retrun JS result Tchromium
Posted: Mon Sep 23, 2024 12:04 pm
by salvadordf
Try loading the DLL with LoadLibrary and then use GetProcAddress for the functions.
CEF4Delphi, WebView4Delphi and WebUI4Delphi use those functions to avoid that issue.
Re: Retrun JS result Tchromium
Posted: Tue Sep 24, 2024 1:29 pm
by subin
Thanks for your reply. Just to know can't I implement InitializeCEF4Delphi and FinalizeCEF4Delphi with in the same dll. In my application I am using 2 different dlls. Can I implement these functions in one dll?
Re: Retrun JS result Tchromium
Posted: Tue Sep 24, 2024 2:52 pm
by salvadordf
It's only allowed to initialize CEF once per process. There's no workaround for this feature.
Using DLLs to embed a browser is complicated because it's not possible to access variables or data between the main application and the code inside the DLL directly. Having multiple DLLs complicates things even more.