Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.

Components understanding

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

Re: Components understanding

Post by salvadordf »

skyknocker wrote: Mon Nov 27, 2017 9:07 pm 1) Could you please explain me why you use two components for browser TChromium and TCEFWindowParent? Why not use just TChromium as in CEF3?
DCEF3 has 3 slightly different TChromium components : normal, OSR and FMX.
CEF4Delphi only has one to make it easier to maintain.
skyknocker wrote: Mon Nov 27, 2017 9:07 pm 2) Additional question to above. What is TChromiumWindow?
TChromiumWindow is just a TCEFWindowParent with a TChromium child. It's used in the SimpleBrowser demo because it's the easier way to have a browser in your app.
skyknocker wrote: Mon Nov 27, 2017 9:07 pm 3) And last one why you use timer, what cause?
The official CEF3 wiki says this in the General Usage section :
Browser life span begins with a call to CefBrowserHost::CreateBrowser() or CefBrowserHost::CreateBrowserSync(). Convenient places to execute this logic include the CefBrowserProcessHandler::OnContextInitialized() callback or platform-specific message handlers like WM_CREATE on Windows.


In Delphi terms that means that you can call TChromium.CreateBrowser after the global context is created or in the TForm.OnCreate.
CEF4Delphi used the TForm.OnShow event but there were times when the global context was not ready yet.

This was the cause of some initialization problems so I added a CefBrowserProcessHandler inside the TCEFApplication to handle the OnContextInitialized event and set TCEFApplication.GlobalContextInitialized to True. Now TChromium.CreateBrowser checks TCEFApplication.GlobalContextInitialized.

The timer was added as a simple way to delay and retry the TChromium.CreateBrowser function when the global context is created. This should be done with synchronization objects but a timer is a much simpler solution for a demo.
skyknocker wrote: Mon Nov 27, 2017 9:07 pm Sorry, may be you have documentation for it, but i could not find answers for my questions.
Please, read this :
https://www.briskbard.com/index.php?lang=en&pageid=cef

That web page has much more information about CEF4Delphi and many links to the official CEF3 project, wiki, documentation, downloads, etc.

The CEF3 documentation is a copy of the original source code comments but, if you want to read the source code comments CEF4Delphi has all the references to those comments in the uCEFLibFunctions.pas and uCEFTypes.pas files.
Post Reply