How to start CEF4Delphi

Post Reply
bobpang
Posts: 7
Joined: Fri Feb 14, 2020 2:38 pm

How to start CEF4Delphi

Post by bobpang » Sat Feb 15, 2020 12:07 am

Hello, there are a few information about cef4delphi on the Internet.
I really can't understand those demos. Come here for help.
Who can tell me the function of those components:
TChromium, TCEFWindowParent, TChromiumWindow, TBufferPanel,TCEFWorkScheduler, TCEFServerComponent, TCEFLinkedWindowParent,TCEFUrlRequestClientComponent
Now, I need to write a Chengxu, read the div element of HTML, and then operate on JS. I saw the demo domvisitor, but for a novice, it's really too difficult, and my English is not good. Who can provide me with a basic demo, just to realize its function, and where else can I get some learning materials?
Thank you very much.

User avatar
salvadordf
Posts: 2608
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: How to start CEF4Delphi

Post by salvadordf » Sat Feb 15, 2020 8:30 am

Hi,

Please, read this document :
https://www.briskbard.com/index.php?lang=en&pageid=cef

Take the code in the SimpleBrowser2 demo as a template for your application and read its code comments.

You can execute JavaScript code with a simple TChromium.ExecuteJavaScript call. In fact, it's the recommended way to search for HTML elements and manipulate the DOM.

bobpang
Posts: 7
Joined: Fri Feb 14, 2020 2:38 pm

Re: How to start CEF4Delphi

Post by bobpang » Sun Feb 16, 2020 12:29 pm

Salvadordf thank you very much for your reply.
Now I have successfully executed a JS code using this function. And use the chromium1jsdialog event to get the return value successfully.
But in demo DOMVisitor,What is the starting sequence?
1、CreateGlobalCEFApp
2、GlobalCEFApp_OnProcessMessageReceived
3、FormCreate
4、FormShow
and when you click the menu,will psotmessage and call GlobalCEFApp_OnProcessMessageReceived to received form process.
so what is this DOMVisitor_OnDocAvailable ? i can't understand comments for it.


By the way, I don't know if the forum or learning materials can add Chinese. I can do translation for free.

bobpang
Posts: 7
Joined: Fri Feb 14, 2020 2:38 pm

Re: How to start CEF4Delphi

Post by bobpang » Sun Feb 16, 2020 12:40 pm

And now ,I have a new problem about cookies.
Just like we open Chrome browser, every web page will have a different tab. If you are visiting different addresses, it is OK to store cookies at the same file. Now I want to use CEF to open the same web page in this program. How can I store cookies and they are not confused? For example, tab1 stores the information of user a, and TAB2 stores the information of user B.
Then how to read their cookies separately at startup?
If my description is not correct, I believe you must have the right idea, please let me get some advice from you sir.
Thanks a lot.

User avatar
salvadordf
Posts: 2608
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: How to start CEF4Delphi

Post by salvadordf » Sun Feb 16, 2020 4:43 pm

bobpang wrote:
Sun Feb 16, 2020 12:29 pm
Salvadordf thank you very much for your reply.
Now I have successfully executed a JS code using this function. And use the chromium1jsdialog event to get the return value successfully.
But in demo DOMVisitor,What is the starting sequence?
1、CreateGlobalCEFApp
2、GlobalCEFApp_OnProcessMessageReceived
3、FormCreate
4、FormShow
and when you click the menu,will psotmessage and call GlobalCEFApp_OnProcessMessageReceived to received form process.
so what is this DOMVisitor_OnDocAvailable ? i can't understand comments for it.
The recommended way to manipulate the DOM is using JavaScript because CEF has a very limited set of functions to do that.

Read the code comments in the JSExtension demo to know all the details about process messages in CEF.
https://github.com/salvadordf/CEF4Delphi/blob/bb33f5d6f5e2821f9a727c3606ece37404f83b59/demos/Delphi_VCL/JavaScript/JSExtension/uJSExtension.pas#L131
bobpang wrote:
Sun Feb 16, 2020 12:29 pm
By the way, I don't know if the forum or learning materials can add Chinese. I can do translation for free.
Thank you very much for your offer! :D

I'll be adding links to personal blogs form the main information page in the coming days :
https://www.briskbard.com/index.php?lang=en&pageid=cef

If you write an article in your blog about CEF4Delphi just let me know and I'll add a link to your site.

User avatar
salvadordf
Posts: 2608
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: How to start CEF4Delphi

Post by salvadordf » Sun Feb 16, 2020 4:48 pm

bobpang wrote:
Sun Feb 16, 2020 12:40 pm
And now ,I have a new problem about cookies.
Just like we open Chrome browser, every web page will have a different tab. If you are visiting different addresses, it is OK to store cookies at the same file. Now I want to use CEF to open the same web page in this program. How can I store cookies and they are not confused? For example, tab1 stores the information of user a, and TAB2 stores the information of user B.
Then how to read their cookies separately at startup?
If my description is not correct, I believe you must have the right idea, please let me get some advice from you sir.
Thanks a lot.
Build the MDIBrowser demo and run it.
Add a check mark in the "Create a new request context for new browsers" box and click on the button to create a new browser.
Each new browser will have independent cookies and cache.

All you need to create an independent browser is to create a new "request context" before the TChromium.CreateBrowser call.
https://github.com/salvadordf/CEF4Delphi/blob/bb33f5d6f5e2821f9a727c3606ece37404f83b59/demos/Delphi_VCL/MDIBrowser/uChildForm.pas#L203

User avatar
salvadordf
Posts: 2608
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: How to start CEF4Delphi

Post by salvadordf » Sun Feb 16, 2020 5:43 pm

I just added some links to a few articles and blogs in other languages with CEF4Delphi information :
https://www.briskbard.com/index.php?lang=en&pageid=cef#moreinfo

bobpang
Posts: 7
Joined: Fri Feb 14, 2020 2:38 pm

Re: How to start CEF4Delphi

Post by bobpang » Fri Feb 21, 2020 7:53 am

thank u

Post Reply