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.

Exception when closing the app

Post Reply
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Exception when closing the app

Post by salvadordf »

Hi,

If you use TChromium + TCEFWindowParent then you need to follow the destruction steps described in the SimpleBrowser2 demo.

Code: Select all

// Destruction steps
// =================
// 1. FormCloseQuery sets CanClose to FALSE calls TChromium.CloseBrowser which triggers the TChromium.OnClose event.
// 2. TChromium.OnClose sends a CEFBROWSER_DESTROY message to destroy CEFWindowParent1 in the main thread, which triggers the TChromium.OnBeforeClose event.
// 3. TChromium.OnBeforeClose sets FCanClose := True and sends WM_CLOSE to the form.
If you are using a URLRequest you need to cancel all requests before closing the application too.
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Exception when closing the app

Post by salvadordf »

I forgot to add one important thing.

Some TChromiumWindow events are executed in the main thread but the TChromium events are executed in a different thread.
You need to destroy TCEFWindowParent in the main thread and that's why SimpleBrowser2 sends a CEFBROWSER_DESTROY message to the form.

Use the SimpleBrowser2 demo as a template.
Post Reply