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.
Closing issues
Closing issues
Hi All,
i am having hard time with closing my browser application by using Windows Shortcuts keys or any other options.
No matter what i do, i always get "Application not responding" or "Application has stopped working" before it closes itself.
are there any ways to terminate the browser without having errors?
Thanks!!
i am having hard time with closing my browser application by using Windows Shortcuts keys or any other options.
No matter what i do, i always get "Application not responding" or "Application has stopped working" before it closes itself.
are there any ways to terminate the browser without having errors?
Thanks!!
- salvadordf
- Posts: 4565
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Closing issues
Hi,
You need to follow the destruction sequence described in the demos.
Read the code comments in the demo you used as template for your application to know the details.
You need to follow the destruction sequence described in the demos.
Read the code comments in the demo you used as template for your application to know the details.
Re: Closing issues
I am sorry 
I have checked the simple browser demo and followed the closing options.
It seems to close okay now.
Many thanks for the advices!!


I have checked the simple browser demo and followed the closing options.
It seems to close okay now.
Many thanks for the advices!!


- salvadordf
- Posts: 4565
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Closing issues
CEF (Chromium) uses several threads and processes that need to be closed correctly before the application can exit.
In general, you should use TForm.OnCloseQuery to cancel the close request while the browser is being destroyed.
There's a slightly different destruction sequence depending on what CEF4Delphi components you used and how you used them :
Many demos use a couple of boolean variables called FCanClose and FClosing to ensure the destruction sequence is done only one time and the form is closed after the browser is correctly destroyed.
If you used TChromium and TCEFWindowParent in normal mode then you have to :
In general, you should use TForm.OnCloseQuery to cancel the close request while the browser is being destroyed.
There's a slightly different destruction sequence depending on what CEF4Delphi components you used and how you used them :
- TChromium and TCEFWindowParent in normal mode.
- TChromium in OSR mode.
- TChromiumWindow.
- Cancel the form destruction and call the TChromium.CloseBrowser procedure.
- Wait until the TChromium.OnClose event is triggered.
- Wait until the TChromium.OnBeforeClose event is triggered and then continue closing the form normally.
Many demos use a couple of boolean variables called FCanClose and FClosing to ensure the destruction sequence is done only one time and the form is closed after the browser is correctly destroyed.
If you used TChromium and TCEFWindowParent in normal mode then you have to :
- Use TForm.OnFormCloseQuery and set CanClose to FALSE. This will cancel the form destruction while you destroy the browser.
- Call TChromium.CloseBrowser inside TForm.OnFormCloseQuery, which will trigger the TChromium.OnClose event.
- Use the TChromium.OnClose event and send a CEFBROWSER_DESTROY message to the form with the TChromium component. You need to send a message because TChromium.OnClose is executed in a different thread and you must destroy all VCL components in the main thread.
- The procedure that handles CEFBROWSER_DESTROY destroys TCEFWindowParent in the main thread, which will trigger the TChromium.OnBeforeClose event.
- Use TChromium.OnBeforeClose to set FCanClose to TRUE and send WM_CLOSE to the form again.
- This time the TForm.OnFormCloseQuery event will set CanClose to TRUE because FCanClose is true and the form can be closed normally.
- salvadordf
- Posts: 4565
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Closing issues
Hi,
The last CEF versions have some issues with some new features and you need to disable them.
Assuming you use the latest CEF4Delphi version, add this code line before the GlobalCEFApp.StartMainProcess call in the LPR file :
This line was added to many demos in the last CEF4Delphi versions.
The last CEF versions have some issues with some new features and you need to disable them.
Assuming you use the latest CEF4Delphi version, add this code line before the GlobalCEFApp.StartMainProcess call in the LPR file :
Code: Select all
GlobalCEFApp.DisableFeatures := 'NetworkService,OutOfBlinkCors';
-
- Posts: 44
- Joined: Sun Jul 07, 2019 1:46 pm
Re: Closing issues
Hello.salvadordf wrote: Sun Aug 04, 2019 7:10 am Hi,
The last CEF versions have some issues with some new features and you need to disable them.
Assuming you use the latest CEF4Delphi version, add this code line before the GlobalCEFApp.StartMainProcess call in the LPR file :This line was added to many demos in the last CEF4Delphi versions.Code: Select all
GlobalCEFApp.DisableFeatures := 'NetworkService,OutOfBlinkCors';
Should everybody add this string?
- salvadordf
- Posts: 4565
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Closing issues
You should add it if you're using the latest CEF4Delphi version and you notice some issues in your app : closing errors, features not working, etc
If future CEF versions we will not be able to disable the Network Service and that line won't be effective but for now, it's recommended to add it.
If future CEF versions we will not be able to disable the Network Service and that line won't be effective but for now, it's recommended to add it.