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.

Close browser without WM_Close

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

Re: Close browser without WM_Close

Post by salvadordf »

Yes, you can replace the WM_CLOSE for a custom message or any other method you like as long as you don't close your application before closing all the browsers correctly.

To close a browser you must follow this sequence if you use TChromium and TCEFWindowParent in normal mode (non OSR mode):
  • Call TChromium.CloseBrowser(True) which triggers the TChromium.OnClose event.
  • In the TChromium.OnClose event you must send a custom message to your app to destroy TCEFWindowParent in the main thread, which triggers the TChromium.OnBeforeClose event.
  • In the TChromium.OnBeforeClose event you must send a different custom message to your app to notify that the browser is correctly closed.
This sequence is used in many demos right before closing the main form but you can close the browsers previously without using WM_CLOSE.
Post Reply