Can't close my browser window and subprocess stays alive
Posted: Wed Sep 08, 2021 5:05 pm
Hi,
I had different CEF windows in my application.
At one point when a form gets closed I want to close that specific CEF instance.
I looked at the documentation but it's different in different examples.
I had this procedures:
But Chromium1Close gets called but Chromium1BeforeClose never.
I had different CEF windows in my application.
At one point when a form gets closed I want to close that specific CEF instance.
I looked at the documentation but it's different in different examples.
I had this procedures:
Code: Select all
procedure TForm_ChromeRepdoc.Chromium1Close(Sender: TObject; const browser: ICefBrowser; var aAction : TCefCloseBrowserAction);
begin
if (browser <> nil) and
(ChromiumWindow1.ChromiumBrowser.BrowserId = browser.Identifier) and
(ChromiumWindow1 <> nil) then
begin
PostMessage(Handle, CEFBROWSER_DESTROY, 0, 0);
aAction := cbaDelay;
end;
end;
procedure TForm_ChromeRepdoc.Chromium1BeforeClose(Sender: TObject; const browser: ICefBrowser);
begin
// The main browser is being destroyed
if (ChromiumWindow1.ChromiumBrowser.BrowserId = 0) then
begin
FCanClose := True;
PostMessage(Handle, WM_CLOSE, 0, 0);
end;
end;
procedure TForm_ChromeRepdoc.FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
begin
try
if BestellId <> TGUID.Empty then
begin
try
TThread.Queue(nil,
procedure
begin
DatensatzVeraendertBestellung();
end);
except on E: Exception do
end;
end;
finally
BestellId := TGuid.Empty;
end;
CanClose := FCanClose;
if not(FClosing) then
begin
FClosing := True;
Visible := False;
ChromiumWindow1.ChromiumBrowser.CloseAllBrowsers();
end;
end;