Move CEFApplication creation out of project source?
Posted: Mon Oct 07, 2019 12:13 pm
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
- 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