Page 1 of 1

Re: how to stop and exit the demo of cef4

Posted: Wed Jan 23, 2019 5:08 pm
by salvadordf
You need to close all browser tabs before closing your application as you can see in the TMainForm.FormCloseQuery procedure.

Set FClosing to TRUE and call the "CloseAllBrowsers" function.

Re: how to stop and exit the demo of cef4

Posted: Fri Jan 25, 2019 8:33 am
by salvadordf
CEF3 requires to follow some steps to close the browsers safely. I usually call that procedure "the destruction sequence" and it's used in all the demos.

The demos have some code comments in the beginning of the unit with all the details. In the case of the TabbedBrowser demo it's here :
https://github.com/salvadordf/CEF4Delph ... m.pas#L144

Code: Select all

// 1. FormCloseQuery hides the form and calls CloseAllBrowsers which calls TChromium.CloseBrowser in all tabs and triggers the TChromium.OnClose event.
// 2. TChromium.OnClose sends a CEFBROWSER_DESTROYWNDPARENT message to destroy TCEFWindowParent in the main thread which triggers a TChromium.OnBeforeClose event.
// 3. TChromium.OnBeforeClose sends a CEFBROWSER_CHECKTAGGEDTABS message to set the TAG property to 1 in the TabSheet containing the TChromium. Then sends WM_CLOSE in case all tabsheets have a TAG = 1.
To close that demo you can do what I commented previously about setting FClosing and calling CloseAllBrowsers, but you can also send a WM_CLOSE to the main form.

If your app doesn't create a tab initially you will also have to modify the BrowserCheckTaggedTabsMsg procedure to set FCanClose to TRUE and send WM_CLOSE to close the app when there are no tabs.