There are code comments giving the details of the "
destruction sequence" in every demo.
In the case of the SimpleOSRBrowser demo inside the OldCEF4Delphi project the code comments are here :
https://github.com/salvadordf/OldCEF4De ... r.pas#L155
Code: Select all
// This is the destruction sequence in OSR mode :
// 1- FormCloseQuery sets CanClose to the initial FCanClose value (False) and calls chrmosr.CloseBrowser(True).
// 2- chrmosr.CloseBrowser(True) will trigger chrmosr.OnClose and we have to
// set "Result" to false and CEF3 will destroy the internal browser immediately.
// 3- chrmosr.OnBeforeClose is triggered because the internal browser was destroyed.
// Now we set FCanClose to True and send WM_CLOSE to the form.
CEF needs to follow some steps when you close a browser and the detailed instructions are in the C source code.
Basically, you need to :
- 1- Call TChromium.CloseBrowser.
- 2- Wait for the TChromium.OnClose event.
- 3- Wait for the TChromium.OnBeforeClose event.
The OSR browsers have a slightly different sequence than the normal browsers but the basic steps are the same.
In your case, the OSR browser needs to set the "
Result" parameter to FALSE in the TChromium.OnClose event in order to destroy the internal browser. When the internal browser is destroyed you will get the TChromium.OnBeforeClose event.
At that point the browser is fully closed and you can close the application if that was the last browser.
If you have more than one browser then you need to close each browser and wait until all of them complete the previous steps before closing the application. For example, the MDIBrowser and ToolBoxBrowser demos wait until all child forms with the browsers are closed before closing the main form.