Page 1 of 1
TChromiumWindow onBeforeClose not firing
Posted: Sat Jan 06, 2018 9:32 pm
by MrDark
The recently added "onBeforeClose" event never fires using TChromiumWindow.
Tested using SimpleBrowser.
I was trying to create a multi-tab browser using TChromiumWindow. The needed event never fires so I can't free the browser object and close the window tab. Any ideas why?
Re: TChromiumWindow onBeforeClose not firing
Posted: Sat Jan 06, 2018 10:18 pm
by salvadordf
Hi,
The complete destruction sequence for TChromiumWindow is described in the code comments inside the SimpleExternalPumpBrowser demo :
https://github.com/salvadordf/CEF4Delph ... rowser.pas
Run that demo and use a breakpoint in ChromiumWindow1BeforeClose.
Re: TChromiumWindow onBeforeClose not firing
Posted: Sat Jan 06, 2018 10:40 pm
by MrDark
I tried the breakpoint before and followed many guides on the destruction sequence. No positive results.
All using the SimpleBrowser.
FYI: I'm using the latest build CEF 3.3239.1723.g071d1c1 on Delphi 2006 (Yes, I know, but I love the old bcc)
Re: TChromiumWindow onBeforeClose not firing
Posted: Sun Jan 07, 2018 8:54 am
by salvadordf
Hi,
The
SimpleExternalPumpBrowser demo has a complete implementation of the destruction sequence for TChromiumWindow. Take its code as a reference for your application.
This is the destruction sequence implemented in that demo :
- The FormCloseQuery event sets CanClose to False and calls TChromiumWindow.CloseBrowser, which triggers the TChromiumWindow.OnClose event.
- The TChromiumWindow.OnClose event calls TChromiumWindow.DestroyChildWindow which triggers the TChromiumWindow.OnBeforeClose event.
- TChromiumWindow.OnBeforeClose sets FCanClose to True and closes the form.
If you follow those steps and TChromiumWindow.DestroyChildWindow returns True in the second step, then TChromiumWindow.OnBeforeClose should be triggered.
TChromiumWindow is a special component that has a slightly different destruction sequence and it's meant for quick browser implementations.
If your application creates several browsers I would recommend you to use the usual TChromium + TCEFWindowParent combination.