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.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.

How can i destroy the browser?

User avatar
Uefi1
Posts: 43
Joined: Tue Aug 24, 2021 1:58 pm

How can i destroy the browser?

Post by Uefi1 »

How can i destroy the browser after create ?

Code: Select all

chromium:=Tchromium.Create(nil);
chromium.DefaultUrl:=url;
if not chromium.Initialized then Chromium.CreateBrowser(nil, '');
while True do begin
if (chromium.Initialized) then Break;
Application.ProcessMessages();
end;
chromium.LoadURL(url);

Code: Select all

chromium.Destroy //NOT WORK
chomium.free //NOT WORK
chromium.CloseBrowser(true); //NOT WORK
Freeandnil(chromium); //NOT WORK
chrom.CloseAllBrowsers; //NOT WORK
And all together does not work either
User avatar
salvadordf
Posts: 4580
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: How can i destroy the browser?

Post by salvadordf »

Use the code in one of the demos as a template for your application.
CEF and Chromium require creating and destroying the browsers following certain steps that are described and implemented in the demos.

Read this document :
https://www.briskbard.com/index.php?lang=en&pageid=cef

Use the code in the SimpleBrowser2 demo in case your application uses VCL.

Avoid using Application.ProcessMessages and waiting loops because they only cause problems with CEF.
User avatar
Uefi1
Posts: 43
Joined: Tue Aug 24, 2021 1:58 pm

Re: How can i destroy the browser?

Post by Uefi1 »

Well, how is the result? *
User avatar
Uefi1
Posts: 43
Joined: Tue Aug 24, 2021 1:58 pm

Re: How can i destroy the browser?

Post by Uefi1 »

Ok from the example

Code: Select all

PostMessage(Handle, CEF_DESTROY, 0, 0); // NOT WORK 
How can I destroy this ebon browser?
User avatar
salvadordf
Posts: 4580
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: How can i destroy the browser?

Post by salvadordf »

Make sure your application has all the code from the demo that you decided to use as a template.
If CEF_DESTROY doesn't work it means that some code wasn't copied to your app.
User avatar
Uefi1
Posts: 43
Joined: Tue Aug 24, 2021 1:58 pm

Re: How can i destroy the browser?

Post by Uefi1 »

NOW i am using code this, Destruction doesn't work help what's wrong then ??????

Code: Select all

var
chrom:Tchromium;
aAction : TCefCloseBrowserAction;
begin
chrom:=Tchromium.Create(nil);
chrom.OnBeforeResourceLoad:=Chromium1BeforeResourceLoad;
chrom.OnLoadingStateChange:=Chromium1LoadingStateChange;
chrom.DefaultUrl:=url;
if not chrom.Initialized then Chrom.CreateBrowser(nil,'');
while True do begin
if (chrom.Initialized) then Break;
Application.ProcessMessages();
end;
chrom.Browser.MainFrame.GetSourceProc(StringVisitor);
end;
aAction := cbaDelay;
PostMessage(Handle, WM_CLOSE, 0, 0);
PostMessage(handle, CEF_DESTROY, 0, 0);
User avatar
salvadordf
Posts: 4580
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: How can i destroy the browser?

Post by salvadordf »

That's not the destruction sequence described in the demos. Please, read my previous comments in this thread.
User avatar
Uefi1
Posts: 43
Joined: Tue Aug 24, 2021 1:58 pm

Re: How can i destroy the browser?

Post by Uefi1 »

I did everything according to the demonstration, it does not work how to be, write the code how long is it right for you chtoli I came here that I came to the battle of psychics
User avatar
Uefi1
Posts: 43
Joined: Tue Aug 24, 2021 1:58 pm

Re: How can i destroy the browser?

Post by Uefi1 »

salvadordf wrote: Sat Oct 30, 2021 10:19 am That's not the destruction sequence described in the demos. Please, read my previous comments in this thread.
Ok, I still don't know how to close and release the dynamically created browser.
I'm waiting for a decision from you
User avatar
salvadordf
Posts: 4580
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: How can i destroy the browser?

Post by salvadordf »

Uefi1 wrote: Tue Nov 16, 2021 3:20 am Ok, I still don't know how to close and release the dynamically created browser.
I'm waiting for a decision from you
My previous answer is still the right one :
salvadordf wrote: Wed Oct 27, 2021 8:55 am Use the code in one of the demos as a template for your application.
CEF and Chromium require creating and destroying the browsers following certain steps that are described and implemented in the demos.

Read this document :
https://www.briskbard.com/index.php?lang=en&pageid=cef

Use the code in the SimpleBrowser2 demo in case your application uses VCL.

Avoid using Application.ProcessMessages and waiting loops because they only cause problems with CEF.
If you need to create and destroy multiple browsers in your application you should use the code TabbedBrowser2, ToolBoxBrowser or MDIBrowser demos.

Use any of those demos as the foundation for your application and build the rest on top of that code.
Post Reply