mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2024-11-15 07:45:56 +01:00
Create independent browsers in FMXTabbedBrowser
This commit is contained in:
parent
dcc10166bd
commit
506f56e583
@ -65,7 +65,7 @@ type
|
||||
public
|
||||
constructor Create(AOwner : TComponent); override;
|
||||
procedure NotifyMoveOrResizeStarted;
|
||||
procedure CreateBrowser;
|
||||
procedure CreateBrowser(aIndependent : boolean);
|
||||
procedure CloseBrowser;
|
||||
procedure ResizeBrowser;
|
||||
procedure ShowBrowser;
|
||||
@ -87,7 +87,8 @@ implementation
|
||||
|
||||
uses
|
||||
FMX.Platform, {$IFDEF MSWINDOWS}FMX.Platform.Win,{$ENDIF}
|
||||
uCEFMiscFunctions, uCEFApplication, uBrowserTab, uMainForm;
|
||||
uCEFMiscFunctions, uCEFApplication, uCEFRequestContext,
|
||||
uBrowserTab, uMainForm;
|
||||
|
||||
procedure TBrowserFrame.BackBtnClick(Sender: TObject);
|
||||
begin
|
||||
@ -331,7 +332,7 @@ begin
|
||||
FMXChromium1.LoadURL(URLEdt.Text);
|
||||
end;
|
||||
|
||||
procedure TBrowserFrame.CreateBrowser;
|
||||
procedure TBrowserFrame.CreateBrowser(aIndependent : boolean);
|
||||
var
|
||||
{$IFDEF MSWINDOWS}
|
||||
TempHandle : HWND;
|
||||
@ -339,11 +340,21 @@ var
|
||||
TempClientRect : TRectF;
|
||||
TempScale : single;
|
||||
{$ENDIF}
|
||||
TempContext : ICefRequestContext;
|
||||
TempCache : string;
|
||||
begin
|
||||
CreateFMXWindowParent;
|
||||
|
||||
if not(FMXChromium1.Initialized) then
|
||||
begin
|
||||
if aIndependent then
|
||||
begin
|
||||
TempCache := GlobalCEFApp.RootCache + '\cache' + inttostr(TBrowserTab(ParentTab).TabID);
|
||||
TempContext := TCefRequestContextRef.New(TempCache, '', '', False, False, False, FMXChromium1.ReqContextHandler)
|
||||
end
|
||||
else
|
||||
TempContext := nil;
|
||||
|
||||
{$IFDEF MSWINDOWS}
|
||||
TempHandle := FmxHandleToHWND(FMXWindowParent.Handle);
|
||||
TempClientRect := FMXWindowParent.ClientRect;
|
||||
@ -354,7 +365,7 @@ begin
|
||||
TempRect.Bottom := round(TempClientRect.Bottom * TempScale);
|
||||
|
||||
FMXChromium1.DefaultUrl := FHomepage;
|
||||
FMXChromium1.CreateBrowser(TempHandle, TempRect);
|
||||
FMXChromium1.CreateBrowser(TempHandle, TempRect, '', TempContext);
|
||||
{$ENDIF}
|
||||
end;
|
||||
end;
|
||||
|
@ -24,7 +24,7 @@ type
|
||||
constructor Create(AOwner: TComponent; aTabID : cardinal; const aCaption : string); reintroduce;
|
||||
procedure NotifyMoveOrResizeStarted;
|
||||
procedure DestroyWindowParent;
|
||||
procedure CreateBrowser(const aHomepage : string);
|
||||
procedure CreateBrowser(const aHomepage : string; aIndependent : boolean);
|
||||
procedure CloseBrowser;
|
||||
procedure ResizeBrowser;
|
||||
procedure ShowBrowser;
|
||||
@ -86,7 +86,7 @@ begin
|
||||
FBrowserFrame.DestroyWindowParent;
|
||||
end;
|
||||
|
||||
procedure TBrowserTab.CreateBrowser(const aHomepage : string);
|
||||
procedure TBrowserTab.CreateBrowser(const aHomepage : string; aIndependent : boolean);
|
||||
begin
|
||||
FBrowserFrame := TBrowserFrame.Create(self);
|
||||
FBrowserFrame.Parent := self;
|
||||
@ -98,7 +98,7 @@ begin
|
||||
FBrowserFrame.OnBrowserTitleChange := BrowserFrame_OnBrowserTitleChange;
|
||||
FBrowserFrame.OnBrowserClosing := BrowserFrame_OnBrowserClosing;
|
||||
|
||||
FBrowserFrame.CreateBrowser;
|
||||
FBrowserFrame.CreateBrowser(aIndependent);
|
||||
end;
|
||||
|
||||
procedure TBrowserTab.CloseBrowser;
|
||||
|
@ -84,6 +84,16 @@ object MainForm: TMainForm
|
||||
StyleLookup = 'passwordeditbutton'
|
||||
TextSettings.Trimming = None
|
||||
end
|
||||
object IndependetChk: TCheckBox
|
||||
Position.X = -36.000000000000000000
|
||||
Position.Y = 176.000000000000000000
|
||||
RotationAngle = 270.000000000000000000
|
||||
Size.Width = 100.000000000000000000
|
||||
Size.Height = 16.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
TabOrder = 0
|
||||
Text = 'Independent'
|
||||
end
|
||||
end
|
||||
object BrowserTabCtrl: TTabControl
|
||||
Align = Client
|
||||
|
@ -38,6 +38,7 @@ type
|
||||
NextTabBtn: TSpeedButton;
|
||||
ShowTabsBtn: TSpeedButton;
|
||||
ShowTabsAction: TAction;
|
||||
IndependetChk: TCheckBox;
|
||||
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormShow(Sender: TObject);
|
||||
@ -145,7 +146,8 @@ end;
|
||||
procedure CreateGlobalCEFApp;
|
||||
begin
|
||||
GlobalCEFApp := TCefApplication.Create;
|
||||
GlobalCEFApp.cache := 'cache';
|
||||
GlobalCEFApp.RootCache := ExtractFileDir(ParamStr(0));
|
||||
GlobalCEFApp.cache := GlobalCEFApp.RootCache + '\cache';
|
||||
GlobalCEFApp.OnContextInitialized := GlobalCEFApp_OnContextInitialized;
|
||||
end;
|
||||
|
||||
@ -274,7 +276,7 @@ begin
|
||||
|
||||
BrowserTabCtrl.TabIndex := pred(BrowserTabCtrl.TabCount);
|
||||
|
||||
TempNewTab.CreateBrowser(HOMEPAGE_URL);
|
||||
TempNewTab.CreateBrowser(HOMEPAGE_URL, IndependetChk.IsChecked);
|
||||
end;
|
||||
|
||||
procedure TMainForm.RemoveTabActionExecute(Sender: TObject);
|
||||
|
@ -2,7 +2,7 @@
|
||||
"UpdateLazPackages" : [
|
||||
{
|
||||
"ForceNotify" : true,
|
||||
"InternalVersion" : 639,
|
||||
"InternalVersion" : 640,
|
||||
"Name" : "cef4delphi_lazarus.lpk",
|
||||
"Version" : "127.3.2"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user