I'm trying to get rid of the TCefApplication.Create in the project source, because:
- My program only needs TChromium when the user has a license for one certain part of it
- Delphi is notorious for having trouble with a modified project source (it's better nowadays)
Doing something like:
procedure InitializeTChromium;
begin
GlobalCEFApp := TCefApplication.Create;
lStarted := GlobalCEFApp.StartMainProcess;
end;
procedure FinalizeTChromium;
begin
if lStarted then GlobalCEFApp.Free;
end;
and calling these from FormShow/FormHide does not work (I get some weird second instance of the form).
But if I call these from FormCreate/FormDestroy *or* use a unit with initialization code like:
Initialization
GlobalCEFApp := TCefApplication.Create;
lStarted := GlobalCEFApp.StartMainProcess;
Finalization
if lStarted then GlobalCEFApp.Free;
it *seems* to work with one caveat: the destruction takes 11 seconds.
(This is regardless of whether I have used the design time TChromium component)
What is the proper way to move TCefApplication construction/destruction out of the project source?
TIA
Jan
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.
Move CEFApplication creation out of project source?
- salvadordf
- Posts: 4565
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Move CEFApplication creation out of project source?
Hi,
If you prefer to remove all the CEF4Delphi code from the DPR file then you need to use a different EXE for the subprocesses.
The "SubProcess" demo shows you how to do that. It initializes and destroys CEF in the initialization and finalization sections of the uCEFLoader.pas file.
Read all the code comments in the PAS and DPR files of that demo.
If you prefer to remove all the CEF4Delphi code from the DPR file then you need to use a different EXE for the subprocesses.
The "SubProcess" demo shows you how to do that. It initializes and destroys CEF in the initialization and finalization sections of the uCEFLoader.pas file.
Read all the code comments in the PAS and DPR files of that demo.