Page 1 of 1
Re: Help / tips
Posted: Wed Jun 19, 2019 3:37 pm
by salvadordf
TChromiumWindow is only intended for adding a simple browser to your app. If you need to handle several browser events I would use a TChromium and a TCEFWindowParent as shown in the SimpleBrowser2 demo.
However, if you don't need to show the browser contents consider using TChromium in OSR mode and if you only need to do some URL requests then consider using a TCEFUrlRequestClientComponent component as shown in the URLRequest demo.
Re: Help / tips
Posted: Wed Jun 19, 2019 4:02 pm
by salvadordf
The single process mode is not supported by CEF. It should only be used for debugging and it's known to cause issues.
CEF can only be initialized once per process and by default, it uses your app's EXE file to create multiple processes.
There are multiple ways to create browsers dynamically. The TabbedBrowser, MDIBrowser or ToolBoxBrowser demos show you some of them and other forum users create the browsers using frames.
The DLLBrowser demo can also be used in this situation. It uses a different EXE for the subprocesses and it can be used for "plugins".
Re: Help / tips
Posted: Wed Jun 19, 2019 4:35 pm
by salvadordf
That's exactly what the
ToolBoxBrowser demo does.
Use the code in that demo as a template for your app. Don't use the
initialization and
finalization sections to initialize CEF unless you use a different EXE for the subprocesses. Preferably, use the code in the ToolBoxBrowser demo to initialize CEF.
Re: Help / tips
Posted: Fri Jun 21, 2019 8:06 pm
by salvadordf
The multiple processes in CEF makes it hard to create a simple component that you can drop in a form.
It's not impossible, but it's not going to look like a regular component.
Follow these steps :
- Use the DLLBrowser demo as a reference. It's not exactly what you need but it's the most similar demo we have.
- Be careful with the CEF Initialization (Configuring and creating GlobalCEFApp). It can only be done once in the main application process.
- GlobalCEFApp must be configured to use an external EXE for the subprocesses.
- You can use TChromium in normal mode or in OSR mode. The DLLBrowser uses the normal mode.
- All browsers must be closed following a destruction sequence. Read all the code comments in the demo to know the details of that sequence.
- You can only destroy GlobalCEFApp after all the browsers are properly closed. After that, you can't initialize it again until you close the application.
- All TChromium instances must call CreateBrowser to initialize them. It's not possible to do any background work if you don't call CreateBrowser.