1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-12-13 21:45:55 +02:00

Added Multi-Browser mode to TChromium

MiniBrowser demo now has the Multi-browser mode enabled.
Added TChromium.MultiBrowserMode
Added TChromium.BrowserById
Added TChromium.BrowserCount
Added TChromium.BrowserIdByIndex
Added TChromium.SelectBrowser
Added TChromium.CloseAllBrowsers
Added TChromium.TryCloseBrowser
This commit is contained in:
Salvador Díaz Fau
2020-05-07 11:46:48 +02:00
parent 5c2204b207
commit 132edb2e88
6 changed files with 883 additions and 437 deletions

View File

@@ -537,7 +537,9 @@ end;
procedure TMiniBrowserFrm.Chromium1Close(Sender: TObject; const browser: ICefBrowser; var aAction : TCefCloseBrowserAction);
begin
if (browser <> nil) and (Chromium1.BrowserId = browser.Identifier) then
if (browser <> nil) and
(Chromium1.BrowserId = browser.Identifier) and
(CEFWindowParent1 <> nil) then
begin
PostMessage(Handle, CEF_DESTROY, 0, 0);
aAction := cbaDelay;
@@ -989,7 +991,10 @@ begin
begin
FClosing := True;
Visible := False;
Chromium1.CloseBrowser(True);
// if TChromium.MultiBrowserMode is enabled then we have to close all
// stored browsers and not only the main browser.
Chromium1.CloseAllBrowsers;
end;
end;
@@ -1000,7 +1005,16 @@ begin
FResponse := TStringList.Create;
FRequest := TStringList.Create;
FNavigation := TStringList.Create;
Chromium1.DefaultURL := MINIBROWSER_HOMEPAGE;
// The MultiBrowserMode store all the browser references in TChromium.
// The first browser reference is the browser in the main form.
// When MiniBrowser allows CEF to create child popup browsers it will also
// store their reference inside TChromium and you can use all the TChromium's
// methods and properties to manipulate those browsers.
// To do that call TChromium.SelectBrowser with the browser ID that will be
// used when you call any method or property in TChromium.
Chromium1.MultiBrowserMode := True;
Chromium1.DefaultURL := MINIBROWSER_HOMEPAGE;
end;
procedure TMiniBrowserFrm.FormDestroy(Sender: TObject);
@@ -1152,7 +1166,7 @@ end;
procedure TMiniBrowserFrm.BrowserDestroyMsg(var aMessage : TMessage);
begin
CEFWindowParent1.Free;
FreeAndNil(CEFWindowParent1);
end;
procedure TMiniBrowserFrm.AddURL(const aURL : string);