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.

Chromium1.CreateBrowser(CEFWindowParent1,''),Fast exit of chorme process

Post Reply
dreamnyj
Posts: 1
Joined: Sat Sep 10, 2022 9:00 am

Chromium1.CreateBrowser(CEFWindowParent1,''),Fast exit of chorme process

Post by dreamnyj »

I use oldcef4delphi in Delphi 11.2,

I created a new test program and it works normally. The web page displays normally.



however



My problem is, in my problematic project.

Code: Select all



GlobalCEFApp := TCefApplication.Create;
if GlobalCEFApp. StartMainProcess then
begin
Application.Initialize;
Application. MainFormOnTaskbar := True;
Application. CreateForm(TFormMain, FormMain);
Application. CreateForm(TFormShowTips, FormShowTips);
Application. CreateForm(TDM, DM);
Application.Run;
end;





procedure TFrameReport. Button1Click(Sender: TObject);
begin

//Fast exit of chorme process
Chromium1.CreateBrowser(CEFWindowParent1,''); 

Chromium1.LoadURL('www.google.com');
end;


The question I want to ask is, does this have anything to do with multithreading or TTimer controls?

The chorme process exited in a flash. Can you give me some advice?
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Chromium1.CreateBrowser(CEFWindowParent1,''),Fast exit of chorme process

Post by salvadordf »

Hi,

The TChromium.CreateBrowser function is asynchronous and it returns before the browser is created.

Use the code in the SimpleBrowser2 demo as a template for your application. That demo uses the TChromium.OnAfterCreated event to send a message to the main form that enables the user interface and clicks the "Go" button to load the initial web page.
dreamnyj
Posts: 1
Joined: Sat Sep 10, 2022 9:00 am

Re: Chromium1.CreateBrowser(CEFWindowParent1,''),Fast exit of chorme process

Post by dreamnyj »

My problem was solved, and the final original is that I
Put A lot of code to prevent program reentry is placed in front of these codes.

Code: Select all



{my other code

...
...
}

GlobalCEFApp := TCefApplication.Create;

if GlobalCEFApp. StartMainProcess then
begin
      Application.Initialize;
      Application.MainFormOnTaskbar := True;
      Application.CreateForm(TFormMain, FormMain);
      Application.Run;
end;


Thank you again for your warm guidance. Good luck.
Last edited by dreamnyj on Sat Sep 10, 2022 10:37 pm, edited 2 times in total.
Post Reply