1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2024-12-04 09:26:52 +02:00

Added FMXTabbedOSRBrowser demo

- Added lincese to FMXTabbedBrowser.dpr
This commit is contained in:
Salvador Díaz Fau 2020-02-11 18:52:26 +01:00
parent a975f8ff89
commit 2906c02231
12 changed files with 3756 additions and 1 deletions

View File

@ -1,3 +1,40 @@
// ************************************************************************
// ***************************** CEF4Delphi *******************************
// ************************************************************************
//
// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based
// browser in Delphi applications.
//
// The original license of DCEF3 still applies to CEF4Delphi.
//
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2020 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************
// ************************************************************************
(*
* Delphi Chromium Embedded 3
*
* Usage allowed under the restrictions of the Lesser GNU General Public License
* or alternatively the restrictions of the Mozilla Public License 1.1
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
*
* Unit owner : Henri Gourvest <hgourvest@gmail.com>
* Web site : http://www.progdigy.com
* Repository : http://code.google.com/p/delphichromiumembedded/
* Group : http://groups.google.com/group/delphichromiumembedded
*
* Embarcadero Technologies, Inc is not permitted to use or redistribute
* this source code without explicit permission.
*
*)
program FMXTabbedBrowser;
uses

View File

@ -0,0 +1,18 @@
del /s /q *.dcu
del /s /q *.exe
del /s /q *.res
del /s /q *.rsm
del /s /q *.log
del /s /q *.dsk
del /s /q *.identcache
del /s /q *.stat
del /s /q *.local
del /s /q *.~*
rmdir Win32\Debug
rmdir Win32\Release
rmdir Win32
rmdir Win64\Debug
rmdir Win64\Release
rmdir Win64
rmdir __history
rmdir __recovery

View File

@ -0,0 +1,76 @@
// ************************************************************************
// ***************************** CEF4Delphi *******************************
// ************************************************************************
//
// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based
// browser in Delphi applications.
//
// The original license of DCEF3 still applies to CEF4Delphi.
//
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2018 Salvador Díaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************
// ************************************************************************
(*
* Delphi Chromium Embedded 3
*
* Usage allowed under the restrictions of the Lesser GNU General Public License
* or alternatively the restrictions of the Mozilla Public License 1.1
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
*
* Unit owner : Henri Gourvest <hgourvest@gmail.com>
* Web site : http://www.progdigy.com
* Repository : http://code.google.com/p/delphichromiumembedded/
* Group : http://groups.google.com/group/delphichromiumembedded
*
* Embarcadero Technologies, Inc is not permitted to use or redistribute
* this source code without explicit permission.
*
*)
program FMXTabbedOSRBrowser;
uses
System.StartUpCopy,
FMX.Forms,
uCEFApplication,
uCEFFMXWorkScheduler,
uMainForm in 'uMainForm.pas' {MainForm},
uBrowserTab in 'uBrowserTab.pas',
uBrowserFrame in 'uBrowserFrame.pas' {BrowserFrame: TFrame},
uFMXApplicationService in 'uFMXApplicationService.pas';
{$R *.res}
{$IFDEF MSWINDOWS}
// CEF3 needs to set the LARGEADDRESSAWARE flag which allows 32-bit processes to use up to 3GB of RAM.
{$SetPEFlags $20}
{$ENDIF}
begin
// GlobalCEFApp creation and initialization moved to a different unit to fix the memory leak described in the bug #89
// https://github.com/salvadordf/CEF4Delphi/issues/89
CreateGlobalCEFApp;
if GlobalCEFApp.StartMainProcess then
begin
Application.Initialize;
Application.CreateForm(TMainForm, MainForm);
Application.Run;
// The form needs to be destroyed *BEFORE* stopping the scheduler.
MainForm.Free;
GlobalFMXWorkScheduler.StopScheduler;
end;
DestroyGlobalCEFApp;
DestroyGlobalFMXWorkScheduler;
end.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,409 @@
// ************************************************************************
// ***************************** CEF4Delphi *******************************
// ************************************************************************
//
// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based
// browser in Delphi applications.
//
// The original license of DCEF3 still applies to CEF4Delphi.
//
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2017 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************
// ************************************************************************
(*
* Delphi Chromium Embedded 3
*
* Usage allowed under the restrictions of the Lesser GNU General Public License
* or alternatively the restrictions of the Mozilla Public License 1.1
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
*
* Unit owner : Henri Gourvest <hgourvest@gmail.com>
* Web site : http://www.progdigy.com
* Repository : http://code.google.com/p/delphichromiumembedded/
* Group : http://groups.google.com/group/delphichromiumembedded
*
* Embarcadero Technologies, Inc is not permitted to use or redistribute
* this source code without explicit permission.
*
*)
// The complete list of compiler versions is here :
// http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Compiler_Versions
{$DEFINE DELPHI_VERSION_UNKNOW}
// Delphi 5
{$IFDEF VER130}
{$UNDEF DELPHI_VERSION_UNKNOW}
{$DEFINE DELPHI5_UP}
{$ENDIF}
// Delphi 6
{$IFDEF VER140}
{$UNDEF DELPHI_VERSION_UNKNOW}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$ENDIF}
// Delphi 7
{$IFDEF VER150}
{$UNDEF DELPHI_VERSION_UNKNOW}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$DEFINE DELPHI7_UP}
{$ENDIF}
// Delphi 8
{$IFDEF VER160}
{$UNDEF DELPHI_VERSION_UNKNOW}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$DEFINE DELPHI7_UP}
{$DEFINE DELPHI8_UP}
{$ENDIF}
// Delphi 2005
{$IFDEF VER170}
{$UNDEF DELPHI_VERSION_UNKNOW}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$DEFINE DELPHI7_UP}
{$DEFINE DELPHI8_UP}
{$DEFINE DELPHI9_UP}
{$ENDIF}
{$IFDEF VER180}
{$UNDEF DELPHI_VERSION_UNKNOW}
// Delphi 2007
{$IFDEF VER185}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$DEFINE DELPHI7_UP}
{$DEFINE DELPHI8_UP}
{$DEFINE DELPHI9_UP}
{$DEFINE DELPHI10_UP}
{$DEFINE DELPHI11_UP}
// Delphi 2006
{$ELSE}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$DEFINE DELPHI7_UP}
{$DEFINE DELPHI8_UP}
{$DEFINE DELPHI9_UP}
{$DEFINE DELPHI10_UP}
{$ENDIF}
{$ENDIF}
// Delphi 2009
{$IFDEF VER200}
{$UNDEF DELPHI_VERSION_UNKNOW}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$DEFINE DELPHI7_UP}
{$DEFINE DELPHI8_UP}
{$DEFINE DELPHI9_UP}
{$DEFINE DELPHI10_UP}
{$DEFINE DELPHI11_UP}
{$DEFINE DELPHI12_UP}
{$ENDIF}
//Delphi 2010
{$IFDEF VER210}
{$UNDEF DELPHI_VERSION_UNKNOW}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$DEFINE DELPHI7_UP}
{$DEFINE DELPHI8_UP}
{$DEFINE DELPHI9_UP}
{$DEFINE DELPHI10_UP}
{$DEFINE DELPHI11_UP}
{$DEFINE DELPHI12_UP}
{$DEFINE DELPHI14_UP}
{$ENDIF}
// Delphi XE
{$IFDEF VER220}
{$UNDEF DELPHI_VERSION_UNKNOW}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$DEFINE DELPHI7_UP}
{$DEFINE DELPHI8_UP}
{$DEFINE DELPHI9_UP}
{$DEFINE DELPHI10_UP}
{$DEFINE DELPHI11_UP}
{$DEFINE DELPHI12_UP}
{$DEFINE DELPHI14_UP}
{$DEFINE DELPHI15_UP}
{$ENDIF}
// Delphi XE2 (First FireMonkey and 64bit compiler)
{$IFDEF VER230}
{$UNDEF DELPHI_VERSION_UNKNOW}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$DEFINE DELPHI7_UP}
{$DEFINE DELPHI8_UP}
{$DEFINE DELPHI9_UP}
{$DEFINE DELPHI10_UP}
{$DEFINE DELPHI11_UP}
{$DEFINE DELPHI12_UP}
{$DEFINE DELPHI14_UP}
{$DEFINE DELPHI15_UP}
{$DEFINE DELPHI16_UP}
{$ENDIF}
// Delphi XE3
{$IFDEF VER240}
{$UNDEF DELPHI_VERSION_UNKNOW}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$DEFINE DELPHI7_UP}
{$DEFINE DELPHI8_UP}
{$DEFINE DELPHI9_UP}
{$DEFINE DELPHI10_UP}
{$DEFINE DELPHI11_UP}
{$DEFINE DELPHI12_UP}
{$DEFINE DELPHI14_UP}
{$DEFINE DELPHI15_UP}
{$DEFINE DELPHI16_UP}
{$DEFINE DELPHI17_UP}
{$ENDIF}
// Delphi XE4
{$IFDEF VER250}
{$UNDEF DELPHI_VERSION_UNKNOW}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$DEFINE DELPHI7_UP}
{$DEFINE DELPHI8_UP}
{$DEFINE DELPHI9_UP}
{$DEFINE DELPHI10_UP}
{$DEFINE DELPHI11_UP}
{$DEFINE DELPHI12_UP}
{$DEFINE DELPHI14_UP}
{$DEFINE DELPHI15_UP}
{$DEFINE DELPHI16_UP}
{$DEFINE DELPHI17_UP}
{$DEFINE DELPHI18_UP}
{$ENDIF}
// Delphi XE5
{$IFDEF VER260}
{$UNDEF DELPHI_VERSION_UNKNOW}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$DEFINE DELPHI7_UP}
{$DEFINE DELPHI8_UP}
{$DEFINE DELPHI9_UP}
{$DEFINE DELPHI10_UP}
{$DEFINE DELPHI11_UP}
{$DEFINE DELPHI12_UP}
{$DEFINE DELPHI14_UP}
{$DEFINE DELPHI15_UP}
{$DEFINE DELPHI16_UP}
{$DEFINE DELPHI17_UP}
{$DEFINE DELPHI18_UP}
{$DEFINE DELPHI19_UP}
{$ENDIF}
// Delphi XE6
{$IFDEF VER270}
{$UNDEF DELPHI_VERSION_UNKNOW}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$DEFINE DELPHI7_UP}
{$DEFINE DELPHI8_UP}
{$DEFINE DELPHI9_UP}
{$DEFINE DELPHI10_UP}
{$DEFINE DELPHI11_UP}
{$DEFINE DELPHI12_UP}
{$DEFINE DELPHI14_UP}
{$DEFINE DELPHI15_UP}
{$DEFINE DELPHI16_UP}
{$DEFINE DELPHI17_UP}
{$DEFINE DELPHI18_UP}
{$DEFINE DELPHI19_UP}
{$DEFINE DELPHI20_UP}
{$ENDIF}
// Delphi XE7
{$IFDEF VER280}
{$UNDEF DELPHI_VERSION_UNKNOW}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$DEFINE DELPHI7_UP}
{$DEFINE DELPHI8_UP}
{$DEFINE DELPHI9_UP}
{$DEFINE DELPHI10_UP}
{$DEFINE DELPHI11_UP}
{$DEFINE DELPHI12_UP}
{$DEFINE DELPHI14_UP}
{$DEFINE DELPHI15_UP}
{$DEFINE DELPHI16_UP}
{$DEFINE DELPHI17_UP}
{$DEFINE DELPHI18_UP}
{$DEFINE DELPHI19_UP}
{$DEFINE DELPHI20_UP}
{$DEFINE DELPHI21_UP}
{$ENDIF}
// Delphi XE8
{$IFDEF VER290}
{$UNDEF DELPHI_VERSION_UNKNOW}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$DEFINE DELPHI7_UP}
{$DEFINE DELPHI8_UP}
{$DEFINE DELPHI9_UP}
{$DEFINE DELPHI10_UP}
{$DEFINE DELPHI11_UP}
{$DEFINE DELPHI12_UP}
{$DEFINE DELPHI14_UP}
{$DEFINE DELPHI15_UP}
{$DEFINE DELPHI16_UP}
{$DEFINE DELPHI17_UP}
{$DEFINE DELPHI18_UP}
{$DEFINE DELPHI19_UP}
{$DEFINE DELPHI20_UP}
{$DEFINE DELPHI21_UP}
{$DEFINE DELPHI22_UP}
{$ENDIF VER290}
// Rad Studio 10 - Delphi Seattle
{$IFDEF VER300}
{$UNDEF DELPHI_VERSION_UNKNOW}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$DEFINE DELPHI7_UP}
{$DEFINE DELPHI8_UP}
{$DEFINE DELPHI9_UP}
{$DEFINE DELPHI10_UP}
{$DEFINE DELPHI11_UP}
{$DEFINE DELPHI12_UP}
{$DEFINE DELPHI14_UP}
{$DEFINE DELPHI15_UP}
{$DEFINE DELPHI16_UP}
{$DEFINE DELPHI17_UP}
{$DEFINE DELPHI18_UP}
{$DEFINE DELPHI19_UP}
{$DEFINE DELPHI20_UP}
{$DEFINE DELPHI21_UP}
{$DEFINE DELPHI22_UP}
{$DEFINE DELPHI23_UP}
{$ENDIF}
// Rad Studio 10.1 - Delphi Berlin
{$IFDEF VER310}
{$UNDEF DELPHI_VERSION_UNKNOW}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$DEFINE DELPHI7_UP}
{$DEFINE DELPHI8_UP}
{$DEFINE DELPHI9_UP}
{$DEFINE DELPHI10_UP}
{$DEFINE DELPHI11_UP}
{$DEFINE DELPHI12_UP}
{$DEFINE DELPHI14_UP}
{$DEFINE DELPHI15_UP}
{$DEFINE DELPHI16_UP}
{$DEFINE DELPHI17_UP}
{$DEFINE DELPHI18_UP}
{$DEFINE DELPHI19_UP}
{$DEFINE DELPHI20_UP}
{$DEFINE DELPHI21_UP}
{$DEFINE DELPHI22_UP}
{$DEFINE DELPHI23_UP}
{$DEFINE DELPHI24_UP}
{$ENDIF}
// Rad Studio 10.2 - Delphi Tokyo
{$IFDEF VER320}
{$UNDEF DELPHI_VERSION_UNKNOW}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$DEFINE DELPHI7_UP}
{$DEFINE DELPHI8_UP}
{$DEFINE DELPHI9_UP}
{$DEFINE DELPHI10_UP}
{$DEFINE DELPHI11_UP}
{$DEFINE DELPHI12_UP}
{$DEFINE DELPHI14_UP}
{$DEFINE DELPHI15_UP}
{$DEFINE DELPHI16_UP}
{$DEFINE DELPHI17_UP}
{$DEFINE DELPHI18_UP}
{$DEFINE DELPHI19_UP}
{$DEFINE DELPHI20_UP}
{$DEFINE DELPHI21_UP}
{$DEFINE DELPHI22_UP}
{$DEFINE DELPHI23_UP}
{$DEFINE DELPHI24_UP}
{$DEFINE DELPHI25_UP}
{$ENDIF}
// Rad Studio 10.3 - Delphi Rio
{$IFDEF VER330}
{$UNDEF DELPHI_VERSION_UNKNOW}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$DEFINE DELPHI7_UP}
{$DEFINE DELPHI8_UP}
{$DEFINE DELPHI9_UP}
{$DEFINE DELPHI10_UP}
{$DEFINE DELPHI11_UP}
{$DEFINE DELPHI12_UP}
{$DEFINE DELPHI14_UP}
{$DEFINE DELPHI15_UP}
{$DEFINE DELPHI16_UP}
{$DEFINE DELPHI17_UP}
{$DEFINE DELPHI18_UP}
{$DEFINE DELPHI19_UP}
{$DEFINE DELPHI20_UP}
{$DEFINE DELPHI21_UP}
{$DEFINE DELPHI22_UP}
{$DEFINE DELPHI23_UP}
{$DEFINE DELPHI24_UP}
{$DEFINE DELPHI25_UP}
{$DEFINE DELPHI26_UP}
{$ENDIF}
{$IFDEF FPC}
{$DEFINE SUPPORTS_INLINE}
{$ELSE}
{$IFDEF DELPHI_VERSION_UNKNOW}
{$DEFINE DELPHI5_UP}
{$DEFINE DELPHI6_UP}
{$DEFINE DELPHI7_UP}
{$DEFINE DELPHI8_UP}
{$DEFINE DELPHI9_UP}
{$DEFINE DELPHI10_UP}
{$DEFINE DELPHI11_UP}
{$DEFINE DELPHI12_UP}
{$DEFINE DELPHI14_UP}
{$DEFINE DELPHI15_UP}
{$DEFINE DELPHI16_UP}
{$DEFINE DELPHI17_UP}
{$DEFINE DELPHI18_UP}
{$DEFINE DELPHI19_UP}
{$DEFINE DELPHI20_UP}
{$DEFINE DELPHI21_UP}
{$DEFINE DELPHI22_UP}
{$DEFINE DELPHI23_UP}
{$DEFINE DELPHI24_UP}
{$DEFINE DELPHI25_UP}
{$DEFINE DELPHI26_UP}
{$ENDIF}
{$ENDIF}
{$IFDEF DELPHI9_UP}
{$DEFINE SUPPORTS_INLINE}
{$ENDIF}

View File

@ -0,0 +1,153 @@
object BrowserFrame: TBrowserFrame
Padding.Left = 1.000000000000000000
Padding.Top = 1.000000000000000000
Padding.Right = 1.000000000000000000
Padding.Bottom = 1.000000000000000000
Size.Width = 1000.000000000000000000
Size.Height = 733.000000000000000000
Size.PlatformDefault = False
object StatusBar: TStatusBar
Padding.Left = 5.000000000000000000
Padding.Right = 5.000000000000000000
Position.X = 1.000000000000000000
Position.Y = 710.000000000000000000
ShowSizeGrip = False
Size.Width = 998.000000000000000000
Size.Height = 22.000000000000000000
Size.PlatformDefault = False
TabOrder = 2
object StatusLbl: TLabel
Align = Client
Size.Width = 988.000000000000000000
Size.Height = 22.000000000000000000
Size.PlatformDefault = False
TabOrder = 0
end
end
object AddressLay: TLayout
Align = Top
Padding.Left = 5.000000000000000000
Padding.Top = 5.000000000000000000
Padding.Right = 5.000000000000000000
Padding.Bottom = 5.000000000000000000
Position.X = 1.000000000000000000
Position.Y = 1.000000000000000000
Size.Width = 998.000000000000000000
Size.Height = 35.000000000000000000
Size.PlatformDefault = False
TabOrder = 4
object GoBtn: TSpeedButton
Align = Right
Margins.Left = 5.000000000000000000
Position.X = 966.000000000000000000
Position.Y = 5.000000000000000000
Size.Width = 27.000000000000000000
Size.Height = 25.000000000000000000
Size.PlatformDefault = False
StyleLookup = 'arrowrighttoolbutton'
Text = 'GoBtn'
OnClick = GoBtnClick
end
object NavButtonLay: TLayout
Align = Left
Margins.Right = 5.000000000000000000
Position.X = 5.000000000000000000
Position.Y = 5.000000000000000000
Size.Width = 115.000000000000000000
Size.Height = 25.000000000000000000
Size.PlatformDefault = False
TabOrder = 2
object BackBtn: TSpeedButton
Align = Left
Margins.Right = 5.000000000000000000
Size.Width = 25.000000000000000000
Size.Height = 25.000000000000000000
Size.PlatformDefault = False
StyleLookup = 'priortoolbutton'
Text = 'BackBtn'
OnClick = BackBtnClick
end
object ForwardBtn: TSpeedButton
Align = Left
Margins.Right = 5.000000000000000000
Position.X = 30.000000000000000000
Size.Width = 25.000000000000000000
Size.Height = 25.000000000000000000
Size.PlatformDefault = False
StyleLookup = 'nexttoolbutton'
Text = 'SpeedButton1'
OnClick = ForwardBtnClick
end
object ReloadBtn: TSpeedButton
Align = Left
Margins.Right = 5.000000000000000000
Position.X = 60.000000000000000000
Size.Width = 25.000000000000000000
Size.Height = 25.000000000000000000
Size.PlatformDefault = False
StyleLookup = 'refreshtoolbutton'
Text = 'SpeedButton1'
OnClick = ReloadBtnClick
end
object StopBtn: TSpeedButton
Align = Left
Position.X = 90.000000000000000000
Size.Width = 25.000000000000000000
Size.Height = 25.000000000000000000
Size.PlatformDefault = False
StyleLookup = 'stoptoolbutton'
Text = 'SpeedButton1'
OnClick = StopBtnClick
end
end
object URLEdt: TEdit
Touch.InteractiveGestures = [LongTap, DoubleTap]
Align = Client
TabOrder = 3
Size.Width = 836.000000000000000000
Size.Height = 25.000000000000000000
Size.PlatformDefault = False
end
end
object FMXBufferPanel1: TFMXBufferPanel
Align = Client
TabOrder = 6
CanFocus = True
Size.Width = 998.000000000000000000
Size.Height = 674.000000000000000000
Size.PlatformDefault = False
OnEnter = FMXBufferPanel1Enter
OnExit = FMXBufferPanel1Exit
OnResize = FMXBufferPanel1Resize
OnClick = FMXBufferPanel1Click
OnMouseDown = FMXBufferPanel1MouseDown
OnMouseMove = FMXBufferPanel1MouseMove
OnMouseUp = FMXBufferPanel1MouseUp
OnMouseLeave = FMXBufferPanel1MouseLeave
OnMouseWheel = FMXBufferPanel1MouseWheel
OnKeyUp = FMXBufferPanel1KeyUp
OnKeyDown = FMXBufferPanel1KeyDown
OnWrongSize = FMXBufferPanel1WrongSize
end
object FMXChromium1: TFMXChromium
OnLoadError = FMXChromium1LoadError
OnLoadingStateChange = FMXChromium1LoadingStateChange
OnAddressChange = FMXChromium1AddressChange
OnTitleChange = FMXChromium1TitleChange
OnTooltip = FMXChromium1Tooltip
OnStatusMessage = FMXChromium1StatusMessage
OnBeforePopup = FMXChromium1BeforePopup
OnAfterCreated = FMXChromium1AfterCreated
OnBeforeClose = FMXChromium1BeforeClose
OnOpenUrlFromTab = FMXChromium1OpenUrlFromTab
OnGetViewRect = FMXChromium1GetViewRect
OnGetScreenPoint = FMXChromium1GetScreenPoint
OnGetScreenInfo = FMXChromium1GetScreenInfo
OnPopupShow = FMXChromium1PopupShow
OnPopupSize = FMXChromium1PopupSize
OnPaint = FMXChromium1Paint
OnCursorChange = FMXChromium1CursorChange
Left = 40
Top = 65
end
end

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,201 @@
// ************************************************************************
// ***************************** CEF4Delphi *******************************
// ************************************************************************
//
// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based
// browser in Delphi applications.
//
// The original license of DCEF3 still applies to CEF4Delphi.
//
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2020 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************
// ************************************************************************
(*
* Delphi Chromium Embedded 3
*
* Usage allowed under the restrictions of the Lesser GNU General Public License
* or alternatively the restrictions of the Mozilla Public License 1.1
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
*
* Unit owner : Henri Gourvest <hgourvest@gmail.com>
* Web site : http://www.progdigy.com
* Repository : http://code.google.com/p/delphichromiumembedded/
* Group : http://groups.google.com/group/delphichromiumembedded
*
* Embarcadero Technologies, Inc is not permitted to use or redistribute
* this source code without explicit permission.
*
*)
unit uBrowserTab;
{$I cef.inc}
interface
uses
Winapi.Windows, System.Classes, System.SysUtils, FMX.Forms, FMX.Types,
FMX.Controls, FMX.TabControl,
uBrowserFrame;
type
TBrowserTab = class(TTabItem)
protected
FBrowserFrame : TBrowserFrame;
FTabID : cardinal;
function GetParentForm : TCustomForm;
procedure BrowserFrame_OnBrowserDestroyed(Sender: TObject);
procedure BrowserFrame_OnBrowserTitleChange(Sender: TObject; const aTitle : string);
procedure BrowserFrame_OnBrowserNeedsResize(Sender: TObject);
public
constructor Create(AOwner: TComponent; aTabID : cardinal; const aCaption : string); reintroduce;
procedure NotifyMoveOrResizeStarted;
procedure CreateBrowser(const aHomepage : string);
procedure CloseBrowser;
procedure ResizeBrowser;
procedure FocusBrowser;
function PostFormMessage(aMsg : cardinal; wParam : cardinal = 0; lParam : integer = 0) : boolean;
procedure SendCaptureLostEvent;
procedure HandleSYSCHAR(const aMessage : TMsg);
procedure HandleSYSKEYDOWN(const aMessage : TMsg);
procedure HandleSYSKEYUP(const aMessage : TMsg);
function HandlePOINTER(const aMessage : TMsg) : boolean;
property TabID : cardinal read FTabID;
property ParentForm : TCustomForm read GetParentForm;
end;
implementation
uses
uMainForm, uCEFConstants;
constructor TBrowserTab.Create(AOwner: TComponent; aTabID : cardinal; const aCaption : string);
begin
inherited Create(AOwner);
FTabID := aTabID;
Text := aCaption;
FBrowserFrame := nil;
Name := 'BrowserTab' + inttostr(aTabID);
end;
function TBrowserTab.GetParentForm : TCustomForm;
var
TempParent : TFMXObject;
begin
TempParent := Parent;
while (TempParent <> nil) and not(TempParent is TCustomForm) do
TempParent := TempParent.Parent;
if (TempParent <> nil) and (TempParent is TCustomForm) then
Result := TCustomForm(TempParent)
else
Result := nil;
end;
function TBrowserTab.PostFormMessage(aMsg, wParam : cardinal; lParam : integer) : boolean;
var
TempForm : TCustomForm;
begin
TempForm := ParentForm;
Result := (TempForm <> nil) and
(TempForm is TMainForm) and
TMainForm(TempForm).PostCustomMessage(aMsg, wParam, lParam);
end;
procedure TBrowserTab.SendCaptureLostEvent;
begin
if (FBrowserFrame <> nil) then
FBrowserFrame.SendCaptureLostEvent;
end;
procedure TBrowserTab.HandleSYSCHAR(const aMessage : TMsg);
begin
if (FBrowserFrame <> nil) then
FBrowserFrame.HandleSYSCHAR(aMessage);
end;
procedure TBrowserTab.HandleSYSKEYDOWN(const aMessage : TMsg);
begin
if (FBrowserFrame <> nil) then
FBrowserFrame.HandleSYSKEYDOWN(aMessage);
end;
procedure TBrowserTab.HandleSYSKEYUP(const aMessage : TMsg);
begin
if (FBrowserFrame <> nil) then
FBrowserFrame.HandleSYSKEYUP(aMessage);
end;
function TBrowserTab.HandlePOINTER(const aMessage : TMsg) : boolean;
begin
Result := (FBrowserFrame <> nil) and
FBrowserFrame.HandlePOINTER(aMessage);
end;
procedure TBrowserTab.NotifyMoveOrResizeStarted;
begin
if (FBrowserFrame <> nil) then
FBrowserFrame.NotifyMoveOrResizeStarted;
end;
procedure TBrowserTab.CreateBrowser(const aHomepage : string);
begin
FBrowserFrame := TBrowserFrame.Create(self);
FBrowserFrame.Parent := self;
FBrowserFrame.Align := TAlignLayout.Client;
FBrowserFrame.Visible := True;
FBrowserFrame.Homepage := aHomepage;
FBrowserFrame.Name := 'BrowserFrame' + inttostr(FTabID);
FBrowserFrame.OnBrowserDestroyed := BrowserFrame_OnBrowserDestroyed;
FBrowserFrame.OnBrowserTitleChange := BrowserFrame_OnBrowserTitleChange;
FBrowserFrame.OnBrowserNeedsResize := BrowserFrame_OnBrowserNeedsResize;
FBrowserFrame.CreateBrowser;
end;
procedure TBrowserTab.CloseBrowser;
begin
if (FBrowserFrame <> nil) then FBrowserFrame.CloseBrowser;
end;
procedure TBrowserTab.ResizeBrowser;
begin
if (FBrowserFrame <> nil) then FBrowserFrame.ResizeBrowser;
end;
procedure TBrowserTab.FocusBrowser;
begin
if (FBrowserFrame <> nil) then FBrowserFrame.FocusBrowser;
end;
procedure TBrowserTab.BrowserFrame_OnBrowserDestroyed(Sender: TObject);
begin
// This event is executed in a CEF thread so we have to send a message to
// destroy the tab in the main application thread.
PostFormMessage(CEF_DESTROYTAB, TabID);
end;
procedure TBrowserTab.BrowserFrame_OnBrowserTitleChange(Sender: TObject; const aTitle : string);
begin
Text := aTitle;
end;
procedure TBrowserTab.BrowserFrame_OnBrowserNeedsResize(Sender: TObject);
begin
PostFormMessage(CEF_PENDINGRESIZE, TabID);
end;
end.

View File

@ -0,0 +1,226 @@
// ************************************************************************
// ***************************** CEF4Delphi *******************************
// ************************************************************************
//
// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based
// browser in Delphi applications.
//
// The original license of DCEF3 still applies to CEF4Delphi.
//
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2020 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************
// ************************************************************************
(*
* Delphi Chromium Embedded 3
*
* Usage allowed under the restrictions of the Lesser GNU General Public License
* or alternatively the restrictions of the Mozilla Public License 1.1
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
*
* Unit owner : Henri Gourvest <hgourvest@gmail.com>
* Web site : http://www.progdigy.com
* Repository : http://code.google.com/p/delphichromiumembedded/
* Group : http://groups.google.com/group/delphichromiumembedded
*
* Embarcadero Technologies, Inc is not permitted to use or redistribute
* this source code without explicit permission.
*
*)
unit uFMXApplicationService;
{$I cef.inc}
// This unit is based in the TFMXApplicationService class created by Takashi Yamamoto
// https://www.gesource.jp/weblog/?p=7367
interface
uses
FMX.Platform;
type
TFMXApplicationService = class(TInterfacedObject, IFMXApplicationService)
protected
class var OldFMXApplicationService: IFMXApplicationService;
class var NewFMXApplicationService: IFMXApplicationService;
public
procedure Run;
function HandleMessage: Boolean;
procedure WaitMessage;
function GetDefaultTitle: string;
function GetTitle: string;
procedure SetTitle(const Value: string);
function GetVersionString: string;
procedure Terminate;
function Terminating: Boolean;
function Running: Boolean;
class procedure AddPlatformService;
property DefaultTitle : string read GetDefaultTitle;
property Title : string read GetTitle write SetTitle;
property AppVersion : string read GetVersionString;
end;
implementation
uses
FMX.Forms,
uMainForm,
uCEFFMXWorkScheduler,
Winapi.Messages, Winapi.Windows,
uCEFApplication, uCEFConstants;
class procedure TFMXApplicationService.AddPlatformService;
begin
if TPlatformServices.Current.SupportsPlatformService(IFMXApplicationService, IInterface(OldFMXApplicationService)) then
begin
TPlatformServices.Current.RemovePlatformService(IFMXApplicationService);
NewFMXApplicationService := TFMXApplicationService.Create;
TPlatformServices.Current.AddPlatformService(IFMXApplicationService, NewFMXApplicationService);
end;
end;
function TFMXApplicationService.GetDefaultTitle: string;
begin
Result := OldFMXApplicationService.GetDefaultTitle;
end;
function TFMXApplicationService.GetTitle: string;
begin
Result := OldFMXApplicationService.GetTitle;
end;
function TFMXApplicationService.GetVersionString: string;
begin
{$IFDEF DELPHI22_UP}
Result := OldFMXApplicationService.GetVersionString;
{$ELSE DELPHI22_UP}
Result := 'unsupported yet';
{$ENDIF DELPHI22_UP}
end;
procedure TFMXApplicationService.Run;
begin
OldFMXApplicationService.Run;
end;
procedure TFMXApplicationService.SetTitle(const Value: string);
begin
OldFMXApplicationService.SetTitle(Value);
end;
procedure TFMXApplicationService.Terminate;
begin
OldFMXApplicationService.Terminate;
end;
function TFMXApplicationService.Terminating: Boolean;
begin
Result := OldFMXApplicationService.Terminating;
end;
procedure TFMXApplicationService.WaitMessage;
begin
OldFMXApplicationService.WaitMessage;
end;
function TFMXApplicationService.Running: Boolean;
begin
{$IFDEF DELPHI24_UP}
Result := OldFMXApplicationService.Running;
{$ELSE}
Result := True;
{$ENDIF}
end;
function TFMXApplicationService.HandleMessage: Boolean;
var
TempMsg : TMsg;
begin
if PeekMessage(TempMsg, 0, 0, 0, PM_NOREMOVE) then
case TempMsg.Message of
WM_MOVE,
WM_MOVING :
if not(Application.Terminated) and
(Application.MainForm <> nil) and
(Application.MainForm is TMainForm) then
TMainForm(Application.MainForm).NotifyMoveOrResizeStarted;
WM_ENTERMENULOOP :
if (TempMsg.wParam = 0) and
(GlobalCEFApp <> nil) then
GlobalCEFApp.OsmodalLoop := True;
WM_EXITMENULOOP :
if (TempMsg.wParam = 0) and
(GlobalCEFApp <> nil) then
GlobalCEFApp.OsmodalLoop := False;
WM_CAPTURECHANGED,
WM_CANCELMODE :
if not(Application.Terminated) and
(Application.MainForm <> nil) and
(Application.MainForm is TMainForm) then
TMainForm(Application.MainForm).SendCaptureLostEvent;
WM_SYSCHAR :
if not(Application.Terminated) and
(Application.MainForm <> nil) and
(Application.MainForm is TMainForm) then
TMainForm(Application.MainForm).HandleSYSCHAR(TempMsg);
WM_SYSKEYDOWN :
if not(Application.Terminated) and
(Application.MainForm <> nil) and
(Application.MainForm is TMainForm) then
TMainForm(Application.MainForm).HandleSYSKEYDOWN(TempMsg);
WM_SYSKEYUP :
if not(Application.Terminated) and
(Application.MainForm <> nil) and
(Application.MainForm is TMainForm) then
TMainForm(Application.MainForm).HandleSYSKEYUP(TempMsg);
WM_POINTERDOWN,
WM_POINTERUPDATE,
WM_POINTERUP :
if not(Application.Terminated) and
(Application.MainForm <> nil) and
(Application.MainForm is TMainForm) then
TMainForm(Application.MainForm).HandlePOINTER(TempMsg);
CEF_INITIALIZED :
if not(Application.Terminated) and
(Application.MainForm <> nil) and
(Application.MainForm is TMainForm) then
TMainForm(Application.MainForm).InitializeUserInterface;
CEF_PENDINGRESIZE :
if not(Application.Terminated) and
(Application.MainForm <> nil) and
(Application.MainForm is TMainForm) then
TMainForm(Application.MainForm).ResizeBrowser(TempMsg.wParam);
CEF_DESTROYTAB :
if not(Application.Terminated) and
(Application.MainForm <> nil) and
(Application.MainForm is TMainForm) then
TMainForm(Application.MainForm).DestroyTab(TempMsg.wParam);
end;
Result := OldFMXApplicationService.HandleMessage;
end;
end.

View File

@ -0,0 +1,73 @@
object MainForm: TMainForm
Left = 0
Top = 0
Caption = 'Initializing. Please, wait...'
ClientHeight = 716
ClientWidth = 979
Position = ScreenCenter
FormFactor.Width = 320
FormFactor.Height = 480
FormFactor.Devices = [Desktop]
OnCreate = FormCreate
OnCloseQuery = FormCloseQuery
OnResize = FormResize
OnShow = FormShow
DesignerMasterStyle = 0
object ButtonLay: TLayout
Align = Left
Enabled = False
Padding.Left = 5.000000000000000000
Padding.Right = 5.000000000000000000
Size.Width = 32.000000000000000000
Size.Height = 716.000000000000000000
Size.PlatformDefault = False
TabOrder = 0
object AddTabBtn: TSpeedButton
Action = AddTabAction
Align = Top
Enabled = True
ImageIndex = -1
Margins.Top = 5.000000000000000000
Position.X = 5.000000000000000000
Position.Y = 5.000000000000000000
Size.Width = 22.000000000000000000
Size.Height = 22.000000000000000000
Size.PlatformDefault = False
StyleLookup = 'additembutton'
end
object RemoveTabBtn: TSpeedButton
Action = RemoveTabAction
Align = Top
Enabled = True
ImageIndex = -1
Margins.Top = 5.000000000000000000
Position.X = 5.000000000000000000
Position.Y = 32.000000000000000000
Size.Width = 22.000000000000000000
Size.Height = 22.000000000000000000
Size.PlatformDefault = False
StyleLookup = 'deleteitembutton'
end
end
object BrowserTabCtrl: TTabControl
Align = Client
Size.Width = 947.000000000000000000
Size.Height = 716.000000000000000000
Size.PlatformDefault = False
TabOrder = 1
TabPosition = PlatformDefault
OnChange = BrowserTabCtrlChange
end
object ActionList1: TActionList
Left = 72
Top = 80
object AddTabAction: TAction
Text = 'AddTabAction'
OnExecute = AddTabActionExecute
end
object RemoveTabAction: TAction
Text = 'RemoveTabAction'
OnExecute = RemoveTabActionExecute
end
end
end

View File

@ -0,0 +1,433 @@
// ************************************************************************
// ***************************** CEF4Delphi *******************************
// ************************************************************************
//
// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based
// browser in Delphi applications.
//
// The original license of DCEF3 still applies to CEF4Delphi.
//
// For more information about CEF4Delphi visit :
// https://www.briskbard.com/index.php?lang=en&pageid=cef
//
// Copyright © 2020 Salvador Diaz Fau. All rights reserved.
//
// ************************************************************************
// ************ vvvv Original license and comments below vvvv *************
// ************************************************************************
(*
* Delphi Chromium Embedded 3
*
* Usage allowed under the restrictions of the Lesser GNU General Public License
* or alternatively the restrictions of the Mozilla Public License 1.1
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
*
* Unit owner : Henri Gourvest <hgourvest@gmail.com>
* Web site : http://www.progdigy.com
* Repository : http://code.google.com/p/delphichromiumembedded/
* Group : http://groups.google.com/group/delphichromiumembedded
*
* Embarcadero Technologies, Inc is not permitted to use or redistribute
* this source code without explicit permission.
*
*)
unit uMainForm;
{$I cef.inc}
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Types, System.Actions,
System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls,
FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.TabControl, FMX.ActnList,
System.Math, FMX.Controls.Presentation, FMX.StdCtrls, FMX.Layouts,
uCEFFMXWorkScheduler;
const
CEF_INITIALIZED = WM_APP + $100;
CEF_DESTROYTAB = WM_APP + $101;
CEF_SHOWBROWSER = WM_APP + $102;
HOMEPAGE_URL = 'https://www.google.com';
DEFAULT_TAB_CAPTION = 'New tab';
type
TMainForm = class(TForm)
ButtonLay: TLayout;
AddTabBtn: TSpeedButton;
RemoveTabBtn: TSpeedButton;
BrowserTabCtrl: TTabControl;
ActionList1: TActionList;
AddTabAction: TAction;
RemoveTabAction: TAction;
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormResize(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure AddTabActionExecute(Sender: TObject);
procedure RemoveTabActionExecute(Sender: TObject);
procedure BrowserTabCtrlChange(Sender: TObject);
protected
// Variables to control when can we destroy the form safely
FCanClose : boolean;
FClosing : boolean;
FLastTabID : cardinal; // Used by NextTabID to generate unique tab IDs
{$IFDEF DELPHI17_UP}
FMouseWheelService : IFMXMouseService;
{$ENDIF}
function GetNextTabID : cardinal;
function CloseAllTabs : boolean;
procedure CloseSelectedTab;
property NextTabID : cardinal read GetNextTabID;
public
procedure InitializeUserInterface;
procedure DestroyTab(aTabID : cardinal);
procedure ResizeBrowser(aTabID : cardinal);
procedure SendCaptureLostEvent;
procedure HandleSYSCHAR(const aMessage : TMsg);
procedure HandleSYSKEYDOWN(const aMessage : TMsg);
procedure HandleSYSKEYUP(const aMessage : TMsg);
function HandlePOINTER(const aMessage : TMsg) : boolean;
function PostCustomMessage(aMessage : cardinal; wParam : cardinal = 0; lParam : integer = 0) : boolean;
procedure NotifyMoveOrResizeStarted;
function GetMousePosition(var aPoint : TPointF) : boolean;
procedure SetBounds(ALeft: Integer; ATop: Integer; AWidth: Integer; AHeight: Integer); override;
end;
var
MainForm: TMainForm;
procedure CreateGlobalCEFApp;
implementation
{$R *.fmx}
uses
FMX.Platform, FMX.Platform.Win,
uCEFMiscFunctions, uCEFApplication, uCEFConstants, uBrowserTab,
uFMXApplicationService;
// This demo shows how to use a TTabControl with TFrames that include
// CEF4Delphi browsers.
// Instead of a regular TTabItem we use a custom TBrowserTab class that
// inherits from TTabItem and instead of a regular TFrame we use a custom
// TBrowserFrame class that inherits from TFrame.
// To create a new tab you need to call TBrowserTab.CreateBrowser in the last
// step to create all the browser components and initialize the browser.
// To close a tab you have to call TBrowserTab.CloseBrowser and wait for a
// CEF_DESTROYTAB message that includes TBrowserTab.TabID in TMessage.wParam.
// Then you find the tab with that unique TabID and you free it.
// TBrowserFrame has all the usual code to close CEF4Delphi browsers following
// a similar destruction sequence than the SimpleFMXBrowser demo :
//
// 1. TBrowserTab.CloseBrowser calls TChromium.CloseBrowser which triggers the
// TChromium.OnClose event.
// 2. TChromium.OnClose sends a CEF_DESTROYWINPARENT message to destroy
// CEFWindowParent1 in the main thread, which triggers the
// TChromium.OnBeforeClose event.
// 3. TChromium.OnBeforeClose executes the TBrowserFrame.OnBrowserDestroyed
// event which will be used in TBrowserTab to send a CEF_DESTROYTAB message
// to the main form to free the tab.
// To close safely this demo you must close all the browser tabs first following
// this steps :
//
// 1. FormCloseQuery sets CanClose to FALSE and calls CloseAllTabs and FClosing
// is set to TRUE.
// 2. Each tab will send a CEF_DESTROYTAB message to free that tab.
// 3. When TTabControl has no tabs then we can set FCanClose to TRUE and close
// the main form.
procedure GlobalCEFApp_OnContextInitialized;
begin
if (MainForm <> nil) then MainForm.PostCustomMessage(CEF_INITIALIZED);
end;
procedure GlobalCEFApp_OnScheduleMessagePumpWork(const aDelayMS : int64);
begin
if (GlobalFMXWorkScheduler <> nil) then GlobalFMXWorkScheduler.ScheduleMessagePumpWork(aDelayMS);
end;
procedure CreateGlobalCEFApp;
begin
// TFMXWorkScheduler will call cef_do_message_loop_work when
// it's told in the GlobalCEFApp.OnScheduleMessagePumpWork event.
// GlobalFMXWorkScheduler needs to be created before the
// GlobalCEFApp.StartMainProcess call.
GlobalFMXWorkScheduler := TFMXWorkScheduler.Create(nil);
GlobalCEFApp := TCefApplication.Create;
GlobalCEFApp.WindowlessRenderingEnabled := True;
GlobalCEFApp.EnableHighDPISupport := True;
GlobalCEFApp.FlashEnabled := False;
GlobalCEFApp.ExternalMessagePump := True;
GlobalCEFApp.MultiThreadedMessageLoop := False;
GlobalCEFApp.cache := 'cache';
GlobalCEFApp.OnScheduleMessagePumpWork := GlobalCEFApp_OnScheduleMessagePumpWork;
GlobalCEFApp.OnContextInitialized := GlobalCEFApp_OnContextInitialized;
end;
procedure TMainForm.NotifyMoveOrResizeStarted;
var
i : integer;
begin
if (BrowserTabCtrl = nil) then exit;
i := pred(BrowserTabCtrl.TabCount);
while (i >= 0) do
begin
TBrowserTab(BrowserTabCtrl.Tabs[i]).NotifyMoveOrResizeStarted;
dec(i);
end;
end;
function TMainForm.GetMousePosition(var aPoint : TPointF) : boolean;
begin
{$IFDEF DELPHI17_UP}
if (FMouseWheelService <> nil) then
begin
aPoint := FMouseWheelService.GetMousePos;
Result := True;
end
else
begin
aPoint.x := 0;
aPoint.y := 0;
Result := False;
end;
{$ELSE}
TempPointF := Platform.GetMousePos;
Result := True;
{$ENDIF}
end;
procedure TMainForm.SetBounds(ALeft, ATop, AWidth, AHeight: Integer);
var
PositionChanged: Boolean;
begin
PositionChanged := (ALeft <> Left) or (ATop <> Top);
inherited SetBounds(ALeft, ATop, AWidth, AHeight);
if PositionChanged then
NotifyMoveOrResizeStarted;
end;
procedure TMainForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
CanClose := FCanClose;
if not(FClosing) then
begin
FClosing := True;
ButtonLay.Enabled := False;
if not(CloseAllTabs) then CanClose := True;
end;
end;
procedure TMainForm.FormCreate(Sender: TObject);
begin
TFMXApplicationService.AddPlatformService;
FCanClose := False;
FClosing := False;
FLastTabID := 0;
{$IFDEF DELPHI17_UP}
if TPlatformServices.Current.SupportsPlatformService(IFMXMouseService) then
FMouseWheelService := TPlatformServices.Current.GetPlatformService(IFMXMouseService) as IFMXMouseService;
{$ENDIF}
end;
procedure TMainForm.FormResize(Sender: TObject);
var
i : integer;
begin
i := pred(BrowserTabCtrl.TabCount);
while (i >= 0) do
begin
TBrowserTab(BrowserTabCtrl.Tabs[i]).ResizeBrowser;
dec(i);
end;
end;
procedure TMainForm.FormShow(Sender: TObject);
begin
if (GlobalCEFApp <> nil) and GlobalCEFApp.GlobalContextInitialized then
InitializeUserInterface;
end;
procedure TMainForm.InitializeUserInterface;
begin
if not(ButtonLay.Enabled) then
begin
ButtonLay.Enabled := True;
Caption := 'FMX Tabbed OSR Browser';
cursor := crDefault;
if (BrowserTabCtrl.TabCount <= 0) then AddTabAction.Execute;
end;
end;
function TMainForm.GetNextTabID : cardinal;
begin
inc(FLastTabID);
Result := FLastTabID;
end;
procedure TMainForm.AddTabActionExecute(Sender: TObject);
var
TempNewTab : TBrowserTab;
begin
TempNewTab := TBrowserTab.Create(BrowserTabCtrl, NextTabID, DEFAULT_TAB_CAPTION);
TempNewTab.Parent := BrowserTabCtrl;
BrowserTabCtrl.TabIndex := pred(BrowserTabCtrl.TabCount);
TempNewTab.CreateBrowser(HOMEPAGE_URL);
end;
procedure TMainForm.RemoveTabActionExecute(Sender: TObject);
begin
CloseSelectedTab;
end;
procedure TMainForm.DestroyTab(aTabID : cardinal);
var
i : integer;
TempText : string;
begin
i := pred(BrowserTabCtrl.TabCount);
while (i >= 0) do
if (TBrowserTab(BrowserTabCtrl.Tabs[i]).TabID = aTabID) then
begin
BrowserTabCtrl.Delete(i);
break;
end
else
dec(i);
if FClosing then
begin
if (BrowserTabCtrl.TabCount <= 0) then
begin
FCanClose := True;
Close;
end;
end
else
begin
// Sometimes TTabControl doesn't draw the new selected tab correctly.
// Changing TTabItem.Text forces the component to redraw all the tabs.
// A nicer solution would be to use a custom ttabcontrol that publishes
// the TTabControl.RealignTabs procedure.
if (BrowserTabCtrl.ActiveTab <> nil) then
begin
TempText := BrowserTabCtrl.ActiveTab.Text;
BrowserTabCtrl.ActiveTab.Text := TempText + ' ';
BrowserTabCtrl.ActiveTab.Text := TempText;
end;
end;
end;
function TMainForm.PostCustomMessage(aMessage, wParam : cardinal; lParam : integer) : boolean;
var
TempHWND : HWND;
begin
TempHWND := FmxHandleToHWND(Handle);
Result := (TempHWND <> 0) and WinApi.Windows.PostMessage(TempHWND, aMessage, wParam, lParam);
end;
procedure TMainForm.BrowserTabCtrlChange(Sender: TObject);
begin
if (BrowserTabCtrl.ActiveTab <> nil) then
TBrowserTab(BrowserTabCtrl.ActiveTab).FocusBrowser;
end;
function TMainForm.CloseAllTabs : boolean;
var
i : integer;
begin
Result := False;
i := pred(BrowserTabCtrl.TabCount);
while (i >= 0) do
begin
TBrowserTab(BrowserTabCtrl.Tabs[i]).CloseBrowser;
Result := True;
dec(i);
end;
end;
procedure TMainForm.ResizeBrowser(aTabID : cardinal);
var
i : integer;
begin
i := pred(BrowserTabCtrl.TabCount);
while (i >= 0) do
if (TBrowserTab(BrowserTabCtrl.Tabs[i]).TabID = aTabID) then
begin
TBrowserTab(BrowserTabCtrl.Tabs[i]).ResizeBrowser;
break;
end
else
dec(i);
end;
procedure TMainForm.CloseSelectedTab;
begin
if (BrowserTabCtrl.ActiveTab <> nil) then
TBrowserTab(BrowserTabCtrl.ActiveTab).CloseBrowser;
end;
procedure TMainForm.SendCaptureLostEvent;
begin
if (BrowserTabCtrl.ActiveTab <> nil) then
TBrowserTab(BrowserTabCtrl.ActiveTab).SendCaptureLostEvent;
end;
procedure TMainForm.HandleSYSCHAR(const aMessage : TMsg);
begin
if (BrowserTabCtrl.ActiveTab <> nil) then
TBrowserTab(BrowserTabCtrl.ActiveTab).HandleSYSCHAR(aMessage);
end;
procedure TMainForm.HandleSYSKEYDOWN(const aMessage : TMsg);
begin
if (BrowserTabCtrl.ActiveTab <> nil) then
TBrowserTab(BrowserTabCtrl.ActiveTab).HandleSYSKEYDOWN(aMessage);
end;
procedure TMainForm.HandleSYSKEYUP(const aMessage : TMsg);
begin
if (BrowserTabCtrl.ActiveTab <> nil) then
TBrowserTab(BrowserTabCtrl.ActiveTab).HandleSYSKEYUP(aMessage);
end;
function TMainForm.HandlePOINTER(const aMessage : TMsg) : boolean;
begin
Result := (BrowserTabCtrl.ActiveTab <> nil) and
TBrowserTab(BrowserTabCtrl.ActiveTab).HandlePOINTER(aMessage);
end;
end.

View File

@ -2,7 +2,7 @@
"UpdateLazPackages" : [
{
"ForceNotify" : true,
"InternalVersion" : 98,
"InternalVersion" : 99,
"Name" : "cef4delphi_lazarus.lpk",
"Version" : "79.1.36.0"
}