You've already forked CEF4Delphi
mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2025-08-04 21:32:54 +02:00
Improved MacOS support thanks to martin_fr
Reorganized demos by OS
This commit is contained in:
@ -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
|
@ -0,0 +1,79 @@
|
||||
// ************************************************************************
|
||||
// ***************************** 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 FMXExternalPumpBrowser;
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI17_UP}
|
||||
System.StartUpCopy,
|
||||
{$ENDIF}
|
||||
FMX.Forms,
|
||||
{$IFDEF MSWINDOWS}
|
||||
WinApi.Windows,
|
||||
{$ENDIF}
|
||||
uCEFApplication,
|
||||
uCEFFMXWorkScheduler,
|
||||
uFMXExternalPumpBrowser in 'uFMXExternalPumpBrowser.pas' {FMXExternalPumpBrowserFrm},
|
||||
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 IMAGE_FILE_LARGE_ADDRESS_AWARE}
|
||||
{$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(TFMXExternalPumpBrowserFrm, FMXExternalPumpBrowserFrm);
|
||||
Application.Run;
|
||||
|
||||
// The form needs to be destroyed *BEFORE* stopping the scheduler.
|
||||
FMXExternalPumpBrowserFrm.Free;
|
||||
|
||||
GlobalFMXWorkScheduler.StopScheduler;
|
||||
end;
|
||||
|
||||
DestroyGlobalCEFApp;
|
||||
DestroyGlobalFMXWorkScheduler;
|
||||
end.
|
File diff suppressed because it is too large
Load Diff
468
demos/Delphi_FMX_Windows/FMXExternalPumpBrowser/cef.inc
Normal file
468
demos/Delphi_FMX_Windows/FMXExternalPumpBrowser/cef.inc
Normal file
@ -0,0 +1,468 @@
|
||||
// ************************************************************************
|
||||
// ***************************** 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}
|
||||
|
||||
// Rad Studio 10.4 - Delphi Sydney
|
||||
{$IFDEF VER340}
|
||||
{$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}
|
||||
{$DEFINE DELPHI27_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF FPC}
|
||||
{$DEFINE SUPPORTS_INLINE}
|
||||
{$IF DEFINED(FPC_FULLVERSION) AND (FPC_FULLVERSION >= 30200)}
|
||||
{$DEFINE FPC_VER_320}
|
||||
{$IFEND}
|
||||
{$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}
|
||||
{$DEFINE DELPHI27_UP}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF DELPHI9_UP}
|
||||
{$DEFINE SUPPORTS_INLINE}
|
||||
{$ENDIF}
|
||||
|
||||
{$IF DEFINED(CPUX32) OR
|
||||
DEFINED(CPU386) OR
|
||||
DEFINED(CPUi386) OR
|
||||
DEFINED(CPUPOWERPC32) OR
|
||||
DEFINED(CPUSPARC32) OR
|
||||
DEFINED(CPU32BITS) OR
|
||||
DEFINED(CPUARM32) OR
|
||||
DEFINED(WIN32) OR
|
||||
DEFINED(IOS32) OR
|
||||
DEFINED(MACOS32) OR
|
||||
DEFINED(LINUX32) OR
|
||||
DEFINED(POSIX32) OR
|
||||
DEFINED(ANDROID32)}
|
||||
{$DEFINE TARGET_32BITS}
|
||||
{$IFEND}
|
||||
|
||||
// Delphi uses MACOS for the new MacOSX and DARWIN is not defined
|
||||
// FPC uses DARWIN for the new MacOSX and MACOS is defined for the classic Macintosh OS (System 7)
|
||||
// We define MACOSX to avoid conflicts in both situations
|
||||
{$IFDEF FPC}
|
||||
{$IFDEF DARWIN}
|
||||
{$DEFINE MACOSX}
|
||||
{$IFEND}
|
||||
{$ELSE}
|
||||
{$IFDEF MACOS}
|
||||
{$DEFINE MACOSX}
|
||||
{$IFEND}
|
||||
{$IFEND}
|
@ -0,0 +1,227 @@
|
||||
// ************************************************************************
|
||||
// ***************************** 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 � 2021 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, {$IFDEF MSWINDOWS}Winapi.Messages, Winapi.Windows,{$ENDIF}
|
||||
uFMXExternalPumpBrowser, uCEFFMXWorkScheduler, 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;
|
||||
{$IFDEF MSWINDOWS}
|
||||
var
|
||||
TempMsg : TMsg;
|
||||
{$ENDIF}
|
||||
begin
|
||||
{$IFDEF MSWINDOWS}
|
||||
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 TFMXExternalPumpBrowserFrm) then
|
||||
TFMXExternalPumpBrowserFrm(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 TFMXExternalPumpBrowserFrm) then
|
||||
TFMXExternalPumpBrowserFrm(Application.MainForm).SendCaptureLostEvent;
|
||||
|
||||
WM_SYSCHAR :
|
||||
if not(Application.Terminated) and
|
||||
(Application.MainForm <> nil) and
|
||||
(Application.MainForm is TFMXExternalPumpBrowserFrm) then
|
||||
TFMXExternalPumpBrowserFrm(Application.MainForm).HandleSYSCHAR(TempMsg);
|
||||
|
||||
WM_SYSKEYDOWN :
|
||||
if not(Application.Terminated) and
|
||||
(Application.MainForm <> nil) and
|
||||
(Application.MainForm is TFMXExternalPumpBrowserFrm) then
|
||||
TFMXExternalPumpBrowserFrm(Application.MainForm).HandleSYSKEYDOWN(TempMsg);
|
||||
|
||||
WM_SYSKEYUP :
|
||||
if not(Application.Terminated) and
|
||||
(Application.MainForm <> nil) and
|
||||
(Application.MainForm is TFMXExternalPumpBrowserFrm) then
|
||||
TFMXExternalPumpBrowserFrm(Application.MainForm).HandleSYSKEYUP(TempMsg);
|
||||
|
||||
WM_KEYDOWN :
|
||||
if not(Application.Terminated) and
|
||||
(Application.MainForm <> nil) and
|
||||
(Application.MainForm is TFMXExternalPumpBrowserFrm) then
|
||||
TFMXExternalPumpBrowserFrm(Application.MainForm).HandleKEYDOWN(TempMsg);
|
||||
|
||||
WM_KEYUP :
|
||||
if not(Application.Terminated) and
|
||||
(Application.MainForm <> nil) and
|
||||
(Application.MainForm is TFMXExternalPumpBrowserFrm) then
|
||||
TFMXExternalPumpBrowserFrm(Application.MainForm).HandleKEYUP(TempMsg);
|
||||
|
||||
WM_POINTERDOWN,
|
||||
WM_POINTERUPDATE,
|
||||
WM_POINTERUP :
|
||||
if not(Application.Terminated) and
|
||||
(Application.MainForm <> nil) and
|
||||
(Application.MainForm is TFMXExternalPumpBrowserFrm) then
|
||||
TFMXExternalPumpBrowserFrm(Application.MainForm).HandlePOINTER(TempMsg);
|
||||
|
||||
CEF_PENDINGRESIZE :
|
||||
if not(Application.Terminated) and
|
||||
(Application.MainForm <> nil) and
|
||||
(Application.MainForm is TFMXExternalPumpBrowserFrm) then
|
||||
TFMXExternalPumpBrowserFrm(Application.MainForm).DoResize;
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
Result := OldFMXApplicationService.HandleMessage;
|
||||
end;
|
||||
|
||||
end.
|
@ -0,0 +1,122 @@
|
||||
object FMXExternalPumpBrowserFrm: TFMXExternalPumpBrowserFrm
|
||||
Left = 0
|
||||
Top = 0
|
||||
Caption = 'Initializing browser. Please wait...'
|
||||
ClientHeight = 633
|
||||
ClientWidth = 800
|
||||
Position = ScreenCenter
|
||||
FormFactor.Width = 320
|
||||
FormFactor.Height = 480
|
||||
FormFactor.Devices = [Desktop]
|
||||
OnCreate = FormCreate
|
||||
OnCloseQuery = FormCloseQuery
|
||||
OnDestroy = FormDestroy
|
||||
OnShow = FormShow
|
||||
OnHide = FormHide
|
||||
DesignerMasterStyle = 0
|
||||
object AddressPnl: TPanel
|
||||
Align = Top
|
||||
Padding.Left = 5.000000000000000000
|
||||
Padding.Top = 5.000000000000000000
|
||||
Padding.Right = 5.000000000000000000
|
||||
Padding.Bottom = 5.000000000000000000
|
||||
Size.Width = 800.000000000000000000
|
||||
Size.Height = 33.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
TabOrder = 1
|
||||
object AddressEdt: TEdit
|
||||
Touch.InteractiveGestures = [LongTap, DoubleTap]
|
||||
Align = Client
|
||||
TabOrder = 0
|
||||
Text = 'https://www.google.com'
|
||||
Size.Width = 709.000000000000000000
|
||||
Size.Height = 23.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
OnEnter = AddressEdtEnter
|
||||
end
|
||||
object Layout1: TLayout
|
||||
Align = Right
|
||||
Padding.Left = 5.000000000000000000
|
||||
Position.X = 714.000000000000000000
|
||||
Position.Y = 5.000000000000000000
|
||||
Size.Width = 81.000000000000000000
|
||||
Size.Height = 23.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
TabOrder = 2
|
||||
object GoBtn: TButton
|
||||
Align = Left
|
||||
Position.X = 5.000000000000000000
|
||||
Size.Width = 36.000000000000000000
|
||||
Size.Height = 23.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
TabOrder = 0
|
||||
Text = 'Go'
|
||||
OnClick = GoBtnClick
|
||||
OnEnter = GoBtnEnter
|
||||
end
|
||||
object SnapshotBtn: TButton
|
||||
Align = Right
|
||||
StyledSettings = [Style, FontColor]
|
||||
Position.X = 45.000000000000000000
|
||||
Size.Width = 36.000000000000000000
|
||||
Size.Height = 23.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
TabOrder = 1
|
||||
Text = #181
|
||||
TextSettings.Font.Family = 'Webdings'
|
||||
TextSettings.Font.Size = 32.000000000000000000
|
||||
OnClick = SnapshotBtnClick
|
||||
OnEnter = SnapshotBtnEnter
|
||||
end
|
||||
end
|
||||
end
|
||||
object Timer1: TTimer
|
||||
Enabled = False
|
||||
Interval = 300
|
||||
OnTimer = Timer1Timer
|
||||
Left = 40
|
||||
Top = 137
|
||||
end
|
||||
object SaveDialog1: TSaveDialog
|
||||
DefaultExt = 'bmp'
|
||||
Filter = 'Bitmap files (*.bmp)|*.BMP'
|
||||
Title = 'Save snapshot'
|
||||
Left = 40
|
||||
Top = 201
|
||||
end
|
||||
object Panel1: TFMXBufferPanel
|
||||
Align = Client
|
||||
TabOrder = 0
|
||||
Color = claTomato
|
||||
CanFocus = True
|
||||
Size.Width = 800.000000000000000000
|
||||
Size.Height = 600.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
OnEnter = Panel1Enter
|
||||
OnExit = Panel1Exit
|
||||
OnResize = Panel1Resize
|
||||
OnClick = Panel1Click
|
||||
OnMouseDown = Panel1MouseDown
|
||||
OnMouseMove = Panel1MouseMove
|
||||
OnMouseUp = Panel1MouseUp
|
||||
OnMouseLeave = Panel1MouseLeave
|
||||
OnMouseWheel = Panel1MouseWheel
|
||||
OnKeyDown = Panel1KeyDown
|
||||
OnDialogKey = Panel1DialogKey
|
||||
end
|
||||
object chrmosr: TFMXChromium
|
||||
OnTooltip = chrmosrTooltip
|
||||
OnCursorChange = chrmosrCursorChange
|
||||
OnBeforePopup = chrmosrBeforePopup
|
||||
OnAfterCreated = chrmosrAfterCreated
|
||||
OnBeforeClose = chrmosrBeforeClose
|
||||
OnGetViewRect = chrmosrGetViewRect
|
||||
OnGetScreenPoint = chrmosrGetScreenPoint
|
||||
OnGetScreenInfo = chrmosrGetScreenInfo
|
||||
OnPopupShow = chrmosrPopupShow
|
||||
OnPopupSize = chrmosrPopupSize
|
||||
OnPaint = chrmosrPaint
|
||||
Left = 40
|
||||
Top = 73
|
||||
end
|
||||
end
|
File diff suppressed because it is too large
Load Diff
18
demos/Delphi_FMX_Windows/FMXTabbedBrowser/00-DeleteDCUs.bat
Normal file
18
demos/Delphi_FMX_Windows/FMXTabbedBrowser/00-DeleteDCUs.bat
Normal 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
|
@ -0,0 +1,68 @@
|
||||
// ************************************************************************
|
||||
// ***************************** 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 � 2021 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
|
||||
System.StartUpCopy,
|
||||
FMX.Forms,
|
||||
uCEFApplication,
|
||||
uMainForm in 'uMainForm.pas' {MainForm},
|
||||
uBrowserTab in 'uBrowserTab.pas',
|
||||
uBrowserFrame in 'uBrowserFrame.pas' {BrowserFrame: TFrame};
|
||||
|
||||
{$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
|
||||
CreateGlobalCEFApp;
|
||||
|
||||
if GlobalCEFApp.StartMainProcess then
|
||||
begin
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TMainForm, MainForm);
|
||||
Application.Run;
|
||||
|
||||
MainForm.Free;
|
||||
end;
|
||||
|
||||
DestroyGlobalCEFApp;
|
||||
end.
|
1235
demos/Delphi_FMX_Windows/FMXTabbedBrowser/FMXTabbedBrowser.dproj
Normal file
1235
demos/Delphi_FMX_Windows/FMXTabbedBrowser/FMXTabbedBrowser.dproj
Normal file
File diff suppressed because it is too large
Load Diff
468
demos/Delphi_FMX_Windows/FMXTabbedBrowser/cef.inc
Normal file
468
demos/Delphi_FMX_Windows/FMXTabbedBrowser/cef.inc
Normal file
@ -0,0 +1,468 @@
|
||||
// ************************************************************************
|
||||
// ***************************** 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}
|
||||
|
||||
// Rad Studio 10.4 - Delphi Sydney
|
||||
{$IFDEF VER340}
|
||||
{$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}
|
||||
{$DEFINE DELPHI27_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF FPC}
|
||||
{$DEFINE SUPPORTS_INLINE}
|
||||
{$IF DEFINED(FPC_FULLVERSION) AND (FPC_FULLVERSION >= 30200)}
|
||||
{$DEFINE FPC_VER_320}
|
||||
{$IFEND}
|
||||
{$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}
|
||||
{$DEFINE DELPHI27_UP}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF DELPHI9_UP}
|
||||
{$DEFINE SUPPORTS_INLINE}
|
||||
{$ENDIF}
|
||||
|
||||
{$IF DEFINED(CPUX32) OR
|
||||
DEFINED(CPU386) OR
|
||||
DEFINED(CPUi386) OR
|
||||
DEFINED(CPUPOWERPC32) OR
|
||||
DEFINED(CPUSPARC32) OR
|
||||
DEFINED(CPU32BITS) OR
|
||||
DEFINED(CPUARM32) OR
|
||||
DEFINED(WIN32) OR
|
||||
DEFINED(IOS32) OR
|
||||
DEFINED(MACOS32) OR
|
||||
DEFINED(LINUX32) OR
|
||||
DEFINED(POSIX32) OR
|
||||
DEFINED(ANDROID32)}
|
||||
{$DEFINE TARGET_32BITS}
|
||||
{$IFEND}
|
||||
|
||||
// Delphi uses MACOS for the new MacOSX and DARWIN is not defined
|
||||
// FPC uses DARWIN for the new MacOSX and MACOS is defined for the classic Macintosh OS (System 7)
|
||||
// We define MACOSX to avoid conflicts in both situations
|
||||
{$IFDEF FPC}
|
||||
{$IFDEF DARWIN}
|
||||
{$DEFINE MACOSX}
|
||||
{$IFEND}
|
||||
{$ELSE}
|
||||
{$IFDEF MACOS}
|
||||
{$DEFINE MACOSX}
|
||||
{$IFEND}
|
||||
{$IFEND}
|
115
demos/Delphi_FMX_Windows/FMXTabbedBrowser/uBrowserFrame.fmx
Normal file
115
demos/Delphi_FMX_Windows/FMXTabbedBrowser/uBrowserFrame.fmx
Normal file
@ -0,0 +1,115 @@
|
||||
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 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 = 3
|
||||
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 WindowParentLay: TLayout
|
||||
Align = Client
|
||||
Size.Width = 998.000000000000000000
|
||||
Size.Height = 696.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
TabOrder = 4
|
||||
OnResize = WindowParentLayResize
|
||||
end
|
||||
object FMXChromium1: TFMXChromium
|
||||
OnLoadError = FMXChromium1LoadError
|
||||
OnLoadingStateChange = FMXChromium1LoadingStateChange
|
||||
OnAddressChange = FMXChromium1AddressChange
|
||||
OnTitleChange = FMXChromium1TitleChange
|
||||
OnBeforePopup = FMXChromium1BeforePopup
|
||||
OnAfterCreated = FMXChromium1AfterCreated
|
||||
OnBeforeClose = FMXChromium1BeforeClose
|
||||
OnClose = FMXChromium1Close
|
||||
OnOpenUrlFromTab = FMXChromium1OpenUrlFromTab
|
||||
Left = 40
|
||||
Top = 65
|
||||
end
|
||||
end
|
376
demos/Delphi_FMX_Windows/FMXTabbedBrowser/uBrowserFrame.pas
Normal file
376
demos/Delphi_FMX_Windows/FMXTabbedBrowser/uBrowserFrame.pas
Normal file
@ -0,0 +1,376 @@
|
||||
// ************************************************************************
|
||||
// ***************************** 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 � 2021 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 uBrowserFrame;
|
||||
|
||||
{$I cef.inc}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
{$IFDEF MSWINDOWS}Winapi.Windows,{$ENDIF}
|
||||
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
|
||||
FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls,
|
||||
FMX.Edit, FMX.Layouts, FMX.Controls.Presentation, FMX.TabControl,
|
||||
uCEFChromiumCore, uCEFFMXChromium, uCEFFMXWindowParent, uCEFInterfaces,
|
||||
uCEFTypes, uCEFConstants;
|
||||
|
||||
type
|
||||
TBrowserTitleEvent = procedure(Sender: TObject; const aTitle : string) of object;
|
||||
|
||||
TBrowserFrame = class(TFrame)
|
||||
FMXChromium1: TFMXChromium;
|
||||
AddressLay: TLayout;
|
||||
GoBtn: TSpeedButton;
|
||||
NavButtonLay: TLayout;
|
||||
BackBtn: TSpeedButton;
|
||||
ForwardBtn: TSpeedButton;
|
||||
ReloadBtn: TSpeedButton;
|
||||
StopBtn: TSpeedButton;
|
||||
URLEdt: TEdit;
|
||||
WindowParentLay: TLayout;
|
||||
|
||||
procedure BackBtnClick(Sender: TObject);
|
||||
procedure ForwardBtnClick(Sender: TObject);
|
||||
procedure ReloadBtnClick(Sender: TObject);
|
||||
procedure StopBtnClick(Sender: TObject);
|
||||
procedure GoBtnClick(Sender: TObject);
|
||||
procedure WindowParentLayResize(Sender: TObject);
|
||||
|
||||
procedure FMXChromium1AfterCreated(Sender: TObject; const browser: ICefBrowser);
|
||||
procedure FMXChromium1BeforeClose(Sender: TObject; const browser: ICefBrowser);
|
||||
procedure FMXChromium1BeforePopup(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; const popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; var extra_info: ICefDictionaryValue; var noJavascriptAccess, Result: Boolean);
|
||||
procedure FMXChromium1OpenUrlFromTab(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; out Result: Boolean);
|
||||
procedure FMXChromium1Close(Sender: TObject; const browser: ICefBrowser; var aAction: TCefCloseBrowserAction);
|
||||
procedure FMXChromium1AddressChange(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const url: ustring);
|
||||
procedure FMXChromium1LoadError(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; errorCode: Integer; const errorText, failedUrl: ustring);
|
||||
procedure FMXChromium1LoadingStateChange(Sender: TObject; const browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean);
|
||||
procedure FMXChromium1TitleChange(Sender: TObject; const browser: ICefBrowser; const title: ustring);
|
||||
|
||||
protected
|
||||
FClosing : boolean; // Indicates that this frame is destroying the browser
|
||||
FHomepage : string; // Used to set the TChromium.DefaultURL property
|
||||
FOnBrowserDestroyed : TNotifyEvent;
|
||||
FOnBrowserClosing : TNotifyEvent;
|
||||
FOnBrowserTitleChange : TBrowserTitleEvent;
|
||||
FMXWindowParent : TFMXWindowParent; // TFMXWindowParent has to be created at runtime. See the SimpleFMXBrowser demo for more details.
|
||||
|
||||
function GetParentForm : TCustomForm;
|
||||
function GetParentTab : TTabItem;
|
||||
function GetFMXWindowParentRect : System.Types.TRect;
|
||||
procedure CreateFMXWindowParent;
|
||||
|
||||
public
|
||||
constructor Create(AOwner : TComponent); override;
|
||||
procedure NotifyMoveOrResizeStarted;
|
||||
procedure CreateBrowser;
|
||||
procedure CloseBrowser;
|
||||
procedure ResizeBrowser;
|
||||
procedure ShowBrowser;
|
||||
procedure HideBrowser;
|
||||
procedure DestroyWindowParent;
|
||||
|
||||
property ParentForm : TCustomForm read GetParentForm;
|
||||
property ParentTab : TTabItem read GetParentTab;
|
||||
property Closing : boolean read FClosing;
|
||||
property Homepage : string read FHomepage write FHomepage;
|
||||
property OnBrowserDestroyed : TNotifyEvent read FOnBrowserDestroyed write FOnBrowserDestroyed;
|
||||
property OnBrowserTitleChange : TBrowserTitleEvent read FOnBrowserTitleChange write FOnBrowserTitleChange;
|
||||
property OnBrowserClosing : TNotifyEvent read FOnBrowserClosing write FOnBrowserClosing;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.fmx}
|
||||
|
||||
uses
|
||||
FMX.Platform, {$IFDEF MSWINDOWS}FMX.Platform.Win,{$ENDIF}
|
||||
uCEFMiscFunctions, uCEFApplication, uBrowserTab, uMainForm;
|
||||
|
||||
procedure TBrowserFrame.BackBtnClick(Sender: TObject);
|
||||
begin
|
||||
FMXChromium1.GoBack;
|
||||
end;
|
||||
|
||||
constructor TBrowserFrame.Create(AOwner : TComponent);
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
|
||||
FClosing := False;
|
||||
FHomepage := '';
|
||||
FOnBrowserDestroyed := nil;
|
||||
FOnBrowserTitleChange := nil;
|
||||
FOnBrowserClosing := nil;
|
||||
FMXWindowParent := nil;
|
||||
end;
|
||||
|
||||
function TBrowserFrame.GetFMXWindowParentRect : System.Types.TRect;
|
||||
var
|
||||
TempRect : TRectF;
|
||||
TempScale : single;
|
||||
begin
|
||||
TempScale := FMXChromium1.ScreenScale;
|
||||
TempRect := WindowParentLay.AbsoluteRect;
|
||||
Result.Left := round(TempRect.Left * TempScale);
|
||||
Result.Top := round(TempRect.Top * TempScale);
|
||||
Result.Right := round(TempRect.Right * TempScale) - 1;
|
||||
Result.Bottom := round(TempREct.Bottom * TempScale) - 1;
|
||||
end;
|
||||
|
||||
procedure TBrowserFrame.ReloadBtnClick(Sender: TObject);
|
||||
begin
|
||||
FMXChromium1.Reload;
|
||||
end;
|
||||
|
||||
procedure TBrowserFrame.ResizeBrowser;
|
||||
begin
|
||||
if (FMXWindowParent <> nil) then
|
||||
FMXWindowParent.SetBounds(GetFMXWindowParentRect);
|
||||
end;
|
||||
|
||||
procedure TBrowserFrame.ShowBrowser;
|
||||
begin
|
||||
if (FMXWindowParent <> nil) then
|
||||
begin
|
||||
FMXWindowParent.WindowState := TWindowState.wsNormal;
|
||||
ResizeBrowser;
|
||||
FMXWindowParent.Show;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TBrowserFrame.HideBrowser;
|
||||
begin
|
||||
if (FMXWindowParent <> nil) then FMXWindowParent.Hide;
|
||||
end;
|
||||
|
||||
procedure TBrowserFrame.DestroyWindowParent;
|
||||
begin
|
||||
if (FMXWindowParent <> nil) then FreeAndNil(FMXWindowParent);
|
||||
end;
|
||||
|
||||
procedure TBrowserFrame.NotifyMoveOrResizeStarted;
|
||||
begin
|
||||
FMXChromium1.NotifyMoveOrResizeStarted;
|
||||
end;
|
||||
|
||||
procedure TBrowserFrame.StopBtnClick(Sender: TObject);
|
||||
begin
|
||||
FMXChromium1.StopLoad;
|
||||
end;
|
||||
|
||||
procedure TBrowserFrame.WindowParentLayResize(Sender: TObject);
|
||||
begin
|
||||
ResizeBrowser;
|
||||
end;
|
||||
|
||||
procedure TBrowserFrame.CreateFMXWindowParent;
|
||||
begin
|
||||
if (FMXWindowParent = nil) then
|
||||
begin
|
||||
FMXWindowParent := TFMXWindowParent.CreateNew(nil);
|
||||
FMXWindowParent.Reparent(ParentForm.Handle);
|
||||
ShowBrowser;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TBrowserFrame.FMXChromium1AddressChange(Sender: TObject;
|
||||
const browser: ICefBrowser; const frame: ICefFrame; const url: ustring);
|
||||
begin
|
||||
TThread.Queue(nil, procedure
|
||||
begin
|
||||
URLEdt.Text := url;
|
||||
end);
|
||||
end;
|
||||
|
||||
procedure TBrowserFrame.FMXChromium1AfterCreated(Sender: TObject;
|
||||
const browser: ICefBrowser);
|
||||
begin
|
||||
TThread.Queue(nil, procedure
|
||||
begin
|
||||
AddressLay.Enabled := True;
|
||||
end);
|
||||
end;
|
||||
|
||||
procedure TBrowserFrame.FMXChromium1BeforeClose(Sender: TObject;
|
||||
const browser: ICefBrowser);
|
||||
begin
|
||||
if assigned(FOnBrowserDestroyed) then FOnBrowserDestroyed(Sender);
|
||||
end;
|
||||
|
||||
procedure TBrowserFrame.FMXChromium1BeforePopup(Sender: TObject;
|
||||
const browser: ICefBrowser; const frame: ICefFrame; const targetUrl,
|
||||
targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition;
|
||||
userGesture: Boolean; const popupFeatures: TCefPopupFeatures;
|
||||
var windowInfo: TCefWindowInfo; var client: ICefClient;
|
||||
var settings: TCefBrowserSettings; var extra_info: ICefDictionaryValue;
|
||||
var noJavascriptAccess, Result: Boolean);
|
||||
begin
|
||||
// For simplicity, this demo blocks all popup windows and new tabs
|
||||
Result := (targetDisposition in [WOD_NEW_FOREGROUND_TAB, WOD_NEW_BACKGROUND_TAB, WOD_NEW_POPUP, WOD_NEW_WINDOW]);
|
||||
end;
|
||||
|
||||
procedure TBrowserFrame.FMXChromium1Close(Sender: TObject;
|
||||
const browser: ICefBrowser; var aAction: TCefCloseBrowserAction);
|
||||
begin
|
||||
aAction := cbaDelay;
|
||||
if assigned(FOnBrowserClosing) then FOnBrowserClosing(self);
|
||||
end;
|
||||
|
||||
procedure TBrowserFrame.FMXChromium1LoadError(Sender: TObject;
|
||||
const browser: ICefBrowser; const frame: ICefFrame; errorCode: Integer;
|
||||
const errorText, failedUrl: ustring);
|
||||
var
|
||||
TempString : string;
|
||||
begin
|
||||
if (errorCode = ERR_ABORTED) then exit;
|
||||
|
||||
TempString := '<html><body bgcolor="white">' +
|
||||
'<h2>Failed to load URL ' + failedUrl +
|
||||
' with error ' + errorText +
|
||||
' (' + inttostr(errorCode) + ').</h2></body></html>';
|
||||
|
||||
FMXChromium1.LoadString(TempString, frame);
|
||||
end;
|
||||
|
||||
procedure TBrowserFrame.FMXChromium1LoadingStateChange(Sender: TObject;
|
||||
const browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean);
|
||||
begin
|
||||
TThread.Queue(nil, procedure
|
||||
begin
|
||||
BackBtn.Enabled := canGoBack;
|
||||
ForwardBtn.Enabled := canGoForward;
|
||||
|
||||
if isLoading then
|
||||
begin
|
||||
ReloadBtn.Enabled := False;
|
||||
StopBtn.Enabled := True;
|
||||
end
|
||||
else
|
||||
begin
|
||||
ReloadBtn.Enabled := True;
|
||||
StopBtn.Enabled := False;
|
||||
end;
|
||||
end);
|
||||
end;
|
||||
|
||||
procedure TBrowserFrame.FMXChromium1OpenUrlFromTab(Sender: TObject;
|
||||
const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring;
|
||||
targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean;
|
||||
out Result: Boolean);
|
||||
begin
|
||||
// For simplicity, this demo blocks all popup windows and new tabs
|
||||
Result := (targetDisposition in [WOD_NEW_FOREGROUND_TAB, WOD_NEW_BACKGROUND_TAB, WOD_NEW_POPUP, WOD_NEW_WINDOW]);
|
||||
end;
|
||||
|
||||
procedure TBrowserFrame.FMXChromium1TitleChange(Sender: TObject;
|
||||
const browser: ICefBrowser; const title: ustring);
|
||||
begin
|
||||
if assigned(FOnBrowserTitleChange) then FOnBrowserTitleChange(Sender, title);
|
||||
end;
|
||||
|
||||
procedure TBrowserFrame.ForwardBtnClick(Sender: TObject);
|
||||
begin
|
||||
FMXChromium1.GoForward;
|
||||
end;
|
||||
|
||||
function TBrowserFrame.GetParentForm : TCustomForm;
|
||||
var
|
||||
TempParent : TTabItem;
|
||||
begin
|
||||
Result := nil;
|
||||
TempParent := ParentTab;
|
||||
|
||||
if (TempParent <> nil) and (TempParent is TBrowserTab) then
|
||||
Result := TBrowserTab(TempParent).ParentForm;
|
||||
end;
|
||||
|
||||
function TBrowserFrame.GetParentTab : TTabItem;
|
||||
var
|
||||
TempParent : TFMXObject;
|
||||
begin
|
||||
Result := nil;
|
||||
TempParent := Parent;
|
||||
|
||||
while (TempParent <> nil) and not(TempParent is TTabItem) do
|
||||
TempParent := TempParent.Parent;
|
||||
|
||||
if (TempParent <> nil) and (TempParent is TTabItem) then
|
||||
Result := TTabItem(TempParent);
|
||||
end;
|
||||
|
||||
procedure TBrowserFrame.GoBtnClick(Sender: TObject);
|
||||
begin
|
||||
FMXChromium1.LoadURL(URLEdt.Text);
|
||||
end;
|
||||
|
||||
procedure TBrowserFrame.CreateBrowser;
|
||||
var
|
||||
{$IFDEF MSWINDOWS}
|
||||
TempHandle : HWND;
|
||||
TempRect : System.Types.TRect;
|
||||
TempClientRect : TRectF;
|
||||
{$ENDIF}
|
||||
begin
|
||||
CreateFMXWindowParent;
|
||||
|
||||
if not(FMXChromium1.Initialized) then
|
||||
begin
|
||||
{$IFDEF MSWINDOWS}
|
||||
TempHandle := FmxHandleToHWND(FMXWindowParent.Handle);
|
||||
TempClientRect := FMXWindowParent.ClientRect;
|
||||
TempRect.Left := round(TempClientRect.Left);
|
||||
TempRect.Top := round(TempClientRect.Top);
|
||||
TempRect.Right := round(TempClientRect.Right);
|
||||
TempRect.Bottom := round(TempClientRect.Bottom);
|
||||
|
||||
FMXChromium1.DefaultUrl := FHomepage;
|
||||
FMXChromium1.CreateBrowser(TempHandle, TempRect);
|
||||
{$ENDIF}
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TBrowserFrame.CloseBrowser;
|
||||
begin
|
||||
if not(FClosing) then
|
||||
begin
|
||||
FClosing := True;
|
||||
AddressLay.Enabled := False;
|
||||
FMXChromium1.CloseBrowser(True);
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
185
demos/Delphi_FMX_Windows/FMXTabbedBrowser/uBrowserTab.pas
Normal file
185
demos/Delphi_FMX_Windows/FMXTabbedBrowser/uBrowserTab.pas
Normal file
@ -0,0 +1,185 @@
|
||||
// ************************************************************************
|
||||
// ***************************** 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 � 2021 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
|
||||
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_OnBrowserClosing(Sender: TObject);
|
||||
|
||||
public
|
||||
constructor Create(AOwner: TComponent; aTabID : cardinal; const aCaption : string); reintroduce;
|
||||
procedure NotifyMoveOrResizeStarted;
|
||||
procedure DestroyWindowParent;
|
||||
procedure CreateBrowser(const aHomepage : string);
|
||||
procedure CloseBrowser;
|
||||
procedure ResizeBrowser;
|
||||
procedure ShowBrowser;
|
||||
procedure HideBrowser;
|
||||
function PostFormMessage(aMsg : cardinal; wParam : cardinal = 0; lParam : integer = 0) : boolean;
|
||||
|
||||
property TabID : cardinal read FTabID;
|
||||
property ParentForm : TCustomForm read GetParentForm;
|
||||
end;
|
||||
|
||||
implementation
|
||||
uses
|
||||
uMainForm;
|
||||
|
||||
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.NotifyMoveOrResizeStarted;
|
||||
begin
|
||||
if (FBrowserFrame <> nil) then
|
||||
FBrowserFrame.NotifyMoveOrResizeStarted;
|
||||
end;
|
||||
|
||||
procedure TBrowserTab.DestroyWindowParent;
|
||||
begin
|
||||
if (FBrowserFrame <> nil) then
|
||||
FBrowserFrame.DestroyWindowParent;
|
||||
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.OnBrowserClosing := BrowserFrame_OnBrowserClosing;
|
||||
|
||||
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.ShowBrowser;
|
||||
begin
|
||||
if (FBrowserFrame <> nil) then FBrowserFrame.ShowBrowser;
|
||||
end;
|
||||
|
||||
procedure TBrowserTab.HideBrowser;
|
||||
begin
|
||||
if (FBrowserFrame <> nil) then FBrowserFrame.HideBrowser;
|
||||
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
|
||||
// This event is executed in a CEF thread so we have to use TThread.Queue to
|
||||
// set the "Text" property in the main application thread.
|
||||
TThread.Queue(nil, procedure
|
||||
begin
|
||||
Text := aTitle;
|
||||
end);
|
||||
end;
|
||||
|
||||
procedure TBrowserTab.BrowserFrame_OnBrowserClosing(Sender: TObject);
|
||||
begin
|
||||
// This event is executed in a CEF thread so we have to send a message to
|
||||
// destroy TFMXWindowParent in the main application thread.
|
||||
PostFormMessage(CEF_DESTROYWINPARENT, TabID);
|
||||
end;
|
||||
|
||||
end.
|
73
demos/Delphi_FMX_Windows/FMXTabbedBrowser/uMainForm.fmx
Normal file
73
demos/Delphi_FMX_Windows/FMXTabbedBrowser/uMainForm.fmx
Normal file
@ -0,0 +1,73 @@
|
||||
object MainForm: TMainForm
|
||||
Left = 0
|
||||
Top = 0
|
||||
Caption = 'Initializing. Please, wait...'
|
||||
ClientHeight = 700
|
||||
ClientWidth = 1032
|
||||
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 = 700.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 = 1000.000000000000000000
|
||||
Size.Height = 700.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
|
507
demos/Delphi_FMX_Windows/FMXTabbedBrowser/uMainForm.pas
Normal file
507
demos/Delphi_FMX_Windows/FMXTabbedBrowser/uMainForm.pas
Normal file
@ -0,0 +1,507 @@
|
||||
// ************************************************************************
|
||||
// ***************************** 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 � 2021 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
|
||||
{$IFDEF MSWINDOWS}
|
||||
Winapi.Messages, Winapi.Windows,
|
||||
{$ENDIF}
|
||||
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
|
||||
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.TabControl,
|
||||
FMX.Controls.Presentation, FMX.StdCtrls, FMX.Layouts, System.Actions,
|
||||
FMX.ActnList, System.Math;
|
||||
|
||||
|
||||
const
|
||||
CEF_INITIALIZED = WM_APP + $100;
|
||||
CEF_DESTROYTAB = WM_APP + $101;
|
||||
CEF_SHOWBROWSER = WM_APP + $102;
|
||||
CEF_DESTROYWINPARENT = WM_APP + $103;
|
||||
|
||||
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 MSWINDOWS}
|
||||
// This is a workaround for the issue #253
|
||||
// https://github.com/salvadordf/CEF4Delphi/issues/253
|
||||
FCustomWindowState : TWindowState;
|
||||
FOldWndPrc : TFNWndProc;
|
||||
FFormStub : Pointer;
|
||||
|
||||
function GetCurrentWindowState : TWindowState;
|
||||
procedure UpdateCustomWindowState;
|
||||
procedure CreateHandle; override;
|
||||
procedure DestroyHandle; override;
|
||||
procedure CustomWndProc(var aMessage: TMessage);
|
||||
{$ENDIF}
|
||||
function GetNextTabID : cardinal;
|
||||
procedure EnableButtonLay;
|
||||
procedure ShowSelectedBrowser;
|
||||
procedure DestroyWindowParent(aTabID : cardinal);
|
||||
procedure DestroyTab(aTabID : cardinal);
|
||||
function CloseAllTabs : boolean;
|
||||
procedure CloseSelectedTab;
|
||||
|
||||
property NextTabID : cardinal read GetNextTabID;
|
||||
public
|
||||
function PostCustomMessage(aMsg : cardinal; aWParam : WPARAM = 0; aLParam : LPARAM = 0) : boolean;
|
||||
procedure NotifyMoveOrResizeStarted;
|
||||
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;
|
||||
|
||||
// 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 CreateGlobalCEFApp;
|
||||
begin
|
||||
GlobalCEFApp := TCefApplication.Create;
|
||||
GlobalCEFApp.cache := 'cache';
|
||||
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;
|
||||
|
||||
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
|
||||
FCanClose := False;
|
||||
FClosing := False;
|
||||
FLastTabID := 0;
|
||||
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
|
||||
EnableButtonLay;
|
||||
end;
|
||||
|
||||
procedure TMainForm.EnableButtonLay;
|
||||
begin
|
||||
if not(ButtonLay.Enabled) then
|
||||
begin
|
||||
ButtonLay.Enabled := True;
|
||||
Caption := 'FMX Tabbed Browser';
|
||||
cursor := crDefault;
|
||||
if (BrowserTabCtrl.TabCount <= 0) then AddTabAction.Execute;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TMainForm.GetNextTabID : cardinal;
|
||||
begin
|
||||
inc(FLastTabID);
|
||||
Result := FLastTabID;
|
||||
end;
|
||||
|
||||
procedure TMainForm.ShowSelectedBrowser;
|
||||
begin
|
||||
if (BrowserTabCtrl.ActiveTab <> nil) then
|
||||
TBrowserTab(BrowserTabCtrl.ActiveTab).ShowBrowser;
|
||||
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;
|
||||
|
||||
{$IFDEF MSWINDOWS}
|
||||
procedure TMainForm.CreateHandle;
|
||||
begin
|
||||
inherited CreateHandle;
|
||||
|
||||
FFormStub := MakeObjectInstance(CustomWndProc);
|
||||
FOldWndPrc := TFNWndProc(SetWindowLongPtr(FmxHandleToHWND(Handle), GWLP_WNDPROC, NativeInt(FFormStub)));
|
||||
end;
|
||||
|
||||
procedure TMainForm.DestroyHandle;
|
||||
begin
|
||||
SetWindowLongPtr(FmxHandleToHWND(Handle), GWLP_WNDPROC, NativeInt(FOldWndPrc));
|
||||
FreeObjectInstance(FFormStub);
|
||||
|
||||
inherited DestroyHandle;
|
||||
end;
|
||||
|
||||
procedure TMainForm.CustomWndProc(var aMessage: TMessage);
|
||||
const
|
||||
SWP_STATECHANGED = $8000; // Undocumented
|
||||
var
|
||||
TempWindowPos : PWindowPos;
|
||||
begin
|
||||
try
|
||||
case aMessage.Msg of
|
||||
WM_ENTERMENULOOP :
|
||||
if (aMessage.wParam = 0) and
|
||||
(GlobalCEFApp <> nil) then
|
||||
GlobalCEFApp.OsmodalLoop := True;
|
||||
|
||||
WM_EXITMENULOOP :
|
||||
if (aMessage.wParam = 0) and
|
||||
(GlobalCEFApp <> nil) then
|
||||
GlobalCEFApp.OsmodalLoop := False;
|
||||
|
||||
WM_MOVE,
|
||||
WM_MOVING : NotifyMoveOrResizeStarted;
|
||||
|
||||
WM_SIZE :
|
||||
if (aMessage.wParam = SIZE_RESTORED) then
|
||||
UpdateCustomWindowState;
|
||||
|
||||
WM_WINDOWPOSCHANGING :
|
||||
begin
|
||||
TempWindowPos := TWMWindowPosChanging(aMessage).WindowPos;
|
||||
if ((TempWindowPos.Flags and SWP_STATECHANGED) <> 0) then
|
||||
UpdateCustomWindowState;
|
||||
end;
|
||||
|
||||
WM_SHOWWINDOW :
|
||||
if (aMessage.wParam <> 0) and (aMessage.lParam = SW_PARENTOPENING) then
|
||||
PostCustomMessage(CEF_SHOWBROWSER);
|
||||
|
||||
CEF_INITIALIZED : EnableButtonLay;
|
||||
CEF_DESTROYWINPARENT : DestroyWindowParent(aMessage.wParam);
|
||||
CEF_DESTROYTAB : DestroyTab(aMessage.wParam);
|
||||
CEF_SHOWBROWSER : ShowSelectedBrowser;
|
||||
end;
|
||||
|
||||
aMessage.Result := CallWindowProc(FOldWndPrc, FmxHandleToHWND(Handle), aMessage.Msg, aMessage.wParam, aMessage.lParam);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TMainForm.CustomWndProc', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMainForm.UpdateCustomWindowState;
|
||||
var
|
||||
TempNewState : TWindowState;
|
||||
begin
|
||||
TempNewState := GetCurrentWindowState;
|
||||
|
||||
if (FCustomWindowState <> TempNewState) then
|
||||
begin
|
||||
// This is a workaround for the issue #253
|
||||
// https://github.com/salvadordf/CEF4Delphi/issues/253
|
||||
if (FCustomWindowState = TWindowState.wsMinimized) then
|
||||
PostCustomMessage(CEF_SHOWBROWSER);
|
||||
|
||||
FCustomWindowState := TempNewState;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TMainForm.GetCurrentWindowState : TWindowState;
|
||||
var
|
||||
TempPlacement : TWindowPlacement;
|
||||
TempHWND : HWND;
|
||||
begin
|
||||
// TForm.WindowState is not updated correctly in FMX forms.
|
||||
// We have to call the GetWindowPlacement function in order to read the window state correctly.
|
||||
|
||||
Result := TWindowState.wsNormal;
|
||||
TempHWND := FmxHandleToHWND(Handle);
|
||||
|
||||
ZeroMemory(@TempPlacement, SizeOf(TWindowPlacement));
|
||||
TempPlacement.Length := SizeOf(TWindowPlacement);
|
||||
|
||||
if GetWindowPlacement(TempHWND, @TempPlacement) then
|
||||
case TempPlacement.showCmd of
|
||||
SW_SHOWMAXIMIZED : Result := TWindowState.wsMaximized;
|
||||
SW_SHOWMINIMIZED : Result := TWindowState.wsMinimized;
|
||||
end;
|
||||
|
||||
if IsIconic(TempHWND) then Result := TWindowState.wsMinimized;
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
procedure TMainForm.DestroyWindowParent(aTabID : cardinal);
|
||||
var
|
||||
i : integer;
|
||||
TempTab : TBrowserTab;
|
||||
begin
|
||||
i := pred(BrowserTabCtrl.TabCount);
|
||||
|
||||
while (i >= 0) do
|
||||
begin
|
||||
TempTab := TBrowserTab(BrowserTabCtrl.Tabs[i]);
|
||||
|
||||
if (TempTab.TabID = aTabID) then
|
||||
begin
|
||||
TempTab.DestroyWindowParent;
|
||||
break;
|
||||
end
|
||||
else
|
||||
dec(i);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMainForm.DestroyTab(aTabID : cardinal);
|
||||
var
|
||||
i : integer;
|
||||
TempTab : TBrowserTab;
|
||||
TempText : string;
|
||||
begin
|
||||
i := pred(BrowserTabCtrl.TabCount);
|
||||
|
||||
while (i >= 0) do
|
||||
begin
|
||||
TempTab := TBrowserTab(BrowserTabCtrl.Tabs[i]);
|
||||
|
||||
if (TempTab.TabID = aTabID) then
|
||||
begin
|
||||
BrowserTabCtrl.Delete(i);
|
||||
break;
|
||||
end
|
||||
else
|
||||
dec(i);
|
||||
end;
|
||||
|
||||
if FClosing then
|
||||
begin
|
||||
if (BrowserTabCtrl.TabCount <= 0) then
|
||||
begin
|
||||
FCanClose := True;
|
||||
Close;
|
||||
end;
|
||||
end
|
||||
else
|
||||
begin
|
||||
ShowSelectedBrowser;
|
||||
|
||||
// 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(aMsg : cardinal; aWParam : WPARAM; aLParam : LPARAM) : boolean;
|
||||
{$IFDEF MSWINDOWS}
|
||||
var
|
||||
TempHWND : HWND;
|
||||
{$ENDIF}
|
||||
begin
|
||||
{$IFDEF MSWINDOWS}
|
||||
TempHWND := FmxHandleToHWND(Handle);
|
||||
Result := (TempHWND <> 0) and WinApi.Windows.PostMessage(TempHWND, aMsg, aWParam, aLParam);
|
||||
{$ELSE}
|
||||
Result := False;
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
procedure TMainForm.BrowserTabCtrlChange(Sender: TObject);
|
||||
var
|
||||
i : integer;
|
||||
begin
|
||||
i := pred(BrowserTabCtrl.TabCount);
|
||||
|
||||
while (i >= 0) do
|
||||
begin
|
||||
if (BrowserTabCtrl.TabIndex = i) then
|
||||
TBrowserTab(BrowserTabCtrl.Tabs[i]).ShowBrowser
|
||||
else
|
||||
TBrowserTab(BrowserTabCtrl.Tabs[i]).HideBrowser;
|
||||
|
||||
dec(i);
|
||||
end;
|
||||
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.CloseSelectedTab;
|
||||
begin
|
||||
if (BrowserTabCtrl.ActiveTab <> nil) then
|
||||
TBrowserTab(BrowserTabCtrl.ActiveTab).CloseBrowser;
|
||||
end;
|
||||
|
||||
end.
|
@ -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
|
@ -0,0 +1,78 @@
|
||||
// ************************************************************************
|
||||
// ***************************** 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}
|
||||
{$IFDEF WIN32}
|
||||
// CEF3 needs to set the LARGEADDRESSAWARE ($20) flag which allows 32-bit processes to use up to 3GB of RAM.
|
||||
{$SetPEFlags $20}
|
||||
{$ENDIF}
|
||||
{$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
468
demos/Delphi_FMX_Windows/FMXTabbedOSRBrowser/cef.inc
Normal file
468
demos/Delphi_FMX_Windows/FMXTabbedOSRBrowser/cef.inc
Normal file
@ -0,0 +1,468 @@
|
||||
// ************************************************************************
|
||||
// ***************************** 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}
|
||||
|
||||
// Rad Studio 10.4 - Delphi Sydney
|
||||
{$IFDEF VER340}
|
||||
{$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}
|
||||
{$DEFINE DELPHI27_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF FPC}
|
||||
{$DEFINE SUPPORTS_INLINE}
|
||||
{$IF DEFINED(FPC_FULLVERSION) AND (FPC_FULLVERSION >= 30200)}
|
||||
{$DEFINE FPC_VER_320}
|
||||
{$IFEND}
|
||||
{$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}
|
||||
{$DEFINE DELPHI27_UP}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF DELPHI9_UP}
|
||||
{$DEFINE SUPPORTS_INLINE}
|
||||
{$ENDIF}
|
||||
|
||||
{$IF DEFINED(CPUX32) OR
|
||||
DEFINED(CPU386) OR
|
||||
DEFINED(CPUi386) OR
|
||||
DEFINED(CPUPOWERPC32) OR
|
||||
DEFINED(CPUSPARC32) OR
|
||||
DEFINED(CPU32BITS) OR
|
||||
DEFINED(CPUARM32) OR
|
||||
DEFINED(WIN32) OR
|
||||
DEFINED(IOS32) OR
|
||||
DEFINED(MACOS32) OR
|
||||
DEFINED(LINUX32) OR
|
||||
DEFINED(POSIX32) OR
|
||||
DEFINED(ANDROID32)}
|
||||
{$DEFINE TARGET_32BITS}
|
||||
{$IFEND}
|
||||
|
||||
// Delphi uses MACOS for the new MacOSX and DARWIN is not defined
|
||||
// FPC uses DARWIN for the new MacOSX and MACOS is defined for the classic Macintosh OS (System 7)
|
||||
// We define MACOSX to avoid conflicts in both situations
|
||||
{$IFDEF FPC}
|
||||
{$IFDEF DARWIN}
|
||||
{$DEFINE MACOSX}
|
||||
{$IFEND}
|
||||
{$ELSE}
|
||||
{$IFDEF MACOS}
|
||||
{$DEFINE MACOSX}
|
||||
{$IFEND}
|
||||
{$IFEND}
|
152
demos/Delphi_FMX_Windows/FMXTabbedOSRBrowser/uBrowserFrame.fmx
Normal file
152
demos/Delphi_FMX_Windows/FMXTabbedOSRBrowser/uBrowserFrame.fmx
Normal file
@ -0,0 +1,152 @@
|
||||
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
|
||||
OnKeyDown = FMXBufferPanel1KeyDown
|
||||
OnDialogKey = FMXBufferPanel1DialogKey
|
||||
end
|
||||
object FMXChromium1: TFMXChromium
|
||||
OnLoadError = FMXChromium1LoadError
|
||||
OnLoadingStateChange = FMXChromium1LoadingStateChange
|
||||
OnAddressChange = FMXChromium1AddressChange
|
||||
OnTitleChange = FMXChromium1TitleChange
|
||||
OnTooltip = FMXChromium1Tooltip
|
||||
OnStatusMessage = FMXChromium1StatusMessage
|
||||
OnCursorChange = FMXChromium1CursorChange
|
||||
OnBeforePopup = FMXChromium1BeforePopup
|
||||
OnAfterCreated = FMXChromium1AfterCreated
|
||||
OnBeforeClose = FMXChromium1BeforeClose
|
||||
OnOpenUrlFromTab = FMXChromium1OpenUrlFromTab
|
||||
OnGetViewRect = FMXChromium1GetViewRect
|
||||
OnGetScreenPoint = FMXChromium1GetScreenPoint
|
||||
OnGetScreenInfo = FMXChromium1GetScreenInfo
|
||||
OnPopupShow = FMXChromium1PopupShow
|
||||
OnPopupSize = FMXChromium1PopupSize
|
||||
OnPaint = FMXChromium1Paint
|
||||
Left = 40
|
||||
Top = 65
|
||||
end
|
||||
end
|
1117
demos/Delphi_FMX_Windows/FMXTabbedOSRBrowser/uBrowserFrame.pas
Normal file
1117
demos/Delphi_FMX_Windows/FMXTabbedOSRBrowser/uBrowserFrame.pas
Normal file
File diff suppressed because it is too large
Load Diff
223
demos/Delphi_FMX_Windows/FMXTabbedOSRBrowser/uBrowserTab.pas
Normal file
223
demos/Delphi_FMX_Windows/FMXTabbedOSRBrowser/uBrowserTab.pas
Normal file
@ -0,0 +1,223 @@
|
||||
// ************************************************************************
|
||||
// ***************************** 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 � 2021 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;
|
||||
procedure SendCaptureLostEvent;
|
||||
{$IFDEF MSWINDOWS}
|
||||
procedure HandleSYSCHAR(const aMessage : TMsg);
|
||||
procedure HandleSYSKEYDOWN(const aMessage : TMsg);
|
||||
procedure HandleSYSKEYUP(const aMessage : TMsg);
|
||||
procedure HandleKEYDOWN(const aMessage : TMsg);
|
||||
procedure HandleKEYUP(const aMessage : TMsg);
|
||||
function HandlePOINTER(const aMessage : TMsg) : boolean;
|
||||
function PostFormMessage(aMsg : cardinal; aWParam : WPARAM = 0; aLParam : LPARAM = 0) : boolean;
|
||||
{$ENDIF}
|
||||
|
||||
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;
|
||||
|
||||
procedure TBrowserTab.SendCaptureLostEvent;
|
||||
begin
|
||||
if (FBrowserFrame <> nil) then
|
||||
FBrowserFrame.SendCaptureLostEvent;
|
||||
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.
|
||||
{$IFDEF MSWINDOWS}
|
||||
PostFormMessage(CEF_DESTROYTAB, TabID);
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
procedure TBrowserTab.BrowserFrame_OnBrowserTitleChange(Sender: TObject; const aTitle : string);
|
||||
begin
|
||||
Text := aTitle;
|
||||
end;
|
||||
|
||||
procedure TBrowserTab.BrowserFrame_OnBrowserNeedsResize(Sender: TObject);
|
||||
begin
|
||||
{$IFDEF MSWINDOWS}
|
||||
PostFormMessage(CEF_PENDINGRESIZE, TabID);
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
{$IFDEF MSWINDOWS}
|
||||
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;
|
||||
|
||||
procedure TBrowserTab.HandleKEYDOWN(const aMessage : TMsg);
|
||||
begin
|
||||
if (FBrowserFrame <> nil) then
|
||||
FBrowserFrame.HandleKEYDOWN(aMessage);
|
||||
end;
|
||||
|
||||
procedure TBrowserTab.HandleKEYUP(const aMessage : TMsg);
|
||||
begin
|
||||
if (FBrowserFrame <> nil) then
|
||||
FBrowserFrame.HandleKEYUP(aMessage);
|
||||
end;
|
||||
|
||||
function TBrowserTab.HandlePOINTER(const aMessage : TMsg) : boolean;
|
||||
begin
|
||||
Result := (FBrowserFrame <> nil) and
|
||||
FBrowserFrame.HandlePOINTER(aMessage);
|
||||
end;
|
||||
|
||||
function TBrowserTab.PostFormMessage(aMsg : cardinal; aWParam : WPARAM; aLParam : LPARAM) : boolean;
|
||||
var
|
||||
TempForm : TCustomForm;
|
||||
begin
|
||||
TempForm := ParentForm;
|
||||
Result := (TempForm <> nil) and
|
||||
(TempForm is TMainForm) and
|
||||
TMainForm(TempForm).PostCustomMessage(aMsg, aWParam, aLParam);
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
end.
|
@ -0,0 +1,239 @@
|
||||
// ************************************************************************
|
||||
// ***************************** 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 � 2021 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, {$IFDEF MSWINDOWS}Winapi.Messages, Winapi.Windows,{$ENDIF}
|
||||
uMainForm, uCEFFMXWorkScheduler, 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;
|
||||
{$IFDEF MSWINDOWS}
|
||||
var
|
||||
TempMsg : TMsg;
|
||||
{$ENDIF}
|
||||
begin
|
||||
{$IFDEF MSWINDOWS}
|
||||
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_KEYDOWN :
|
||||
if not(Application.Terminated) and
|
||||
(Application.MainForm <> nil) and
|
||||
(Application.MainForm is TMainForm) then
|
||||
TMainForm(Application.MainForm).HandleKEYDOWN(TempMsg);
|
||||
|
||||
WM_KEYUP :
|
||||
if not(Application.Terminated) and
|
||||
(Application.MainForm <> nil) and
|
||||
(Application.MainForm is TMainForm) then
|
||||
TMainForm(Application.MainForm).HandleKEYUP(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(cardinal(TempMsg.wParam));
|
||||
|
||||
CEF_DESTROYTAB :
|
||||
if not(Application.Terminated) and
|
||||
(Application.MainForm <> nil) and
|
||||
(Application.MainForm is TMainForm) then
|
||||
TMainForm(Application.MainForm).DestroyTab(cardinal(TempMsg.wParam));
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
Result := OldFMXApplicationService.HandleMessage;
|
||||
end;
|
||||
|
||||
end.
|
73
demos/Delphi_FMX_Windows/FMXTabbedOSRBrowser/uMainForm.fmx
Normal file
73
demos/Delphi_FMX_Windows/FMXTabbedOSRBrowser/uMainForm.fmx
Normal 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
|
454
demos/Delphi_FMX_Windows/FMXTabbedOSRBrowser/uMainForm.pas
Normal file
454
demos/Delphi_FMX_Windows/FMXTabbedOSRBrowser/uMainForm.pas
Normal file
@ -0,0 +1,454 @@
|
||||
// ************************************************************************
|
||||
// ***************************** 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 � 2021 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 NotifyMoveOrResizeStarted;
|
||||
function GetMousePosition(var aPoint : TPointF) : boolean;
|
||||
procedure SetBounds(ALeft: Integer; ATop: Integer; AWidth: Integer; AHeight: Integer); override;
|
||||
{$IFDEF MSWINDOWS}
|
||||
procedure HandleSYSCHAR(const aMessage : TMsg);
|
||||
procedure HandleSYSKEYDOWN(const aMessage : TMsg);
|
||||
procedure HandleSYSKEYUP(const aMessage : TMsg);
|
||||
procedure HandleKEYDOWN(const aMessage : TMsg);
|
||||
procedure HandleKEYUP(const aMessage : TMsg);
|
||||
function HandlePOINTER(const aMessage : TMsg) : boolean;
|
||||
function PostCustomMessage(aMsg : cardinal; aWParam : WPARAM = 0; aLParam : LPARAM = 0) : boolean;
|
||||
{$ENDIF}
|
||||
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 in OSR mode and using a message pump.
|
||||
|
||||
// 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 FMXExternalPumpBrowser demo :
|
||||
//
|
||||
// 1- TChromium.CloseBrowser(True) will trigger TChromium.OnClose and the default
|
||||
// implementation will destroy the internal browser immediately, which will
|
||||
// trigger the TChromium.OnBeforeClose event.
|
||||
// 2- TChromium.OnBeforeClose sends 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
|
||||
{$IFDEF MSWINDOWS}
|
||||
if (MainForm <> nil) then
|
||||
MainForm.PostCustomMessage(CEF_INITIALIZED);
|
||||
{$ENDIF}
|
||||
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.ExternalMessagePump := True;
|
||||
GlobalCEFApp.MultiThreadedMessageLoop := False;
|
||||
GlobalCEFApp.cache := 'cache';
|
||||
GlobalCEFApp.OnScheduleMessagePumpWork := GlobalCEFApp_OnScheduleMessagePumpWork;
|
||||
GlobalCEFApp.OnContextInitialized := GlobalCEFApp_OnContextInitialized;
|
||||
//GlobalCEFApp.EnableGPU := True;
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
{$IFDEF MSWINDOWS}
|
||||
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;
|
||||
|
||||
procedure TMainForm.HandleKEYDOWN(const aMessage : TMsg);
|
||||
begin
|
||||
if (BrowserTabCtrl.ActiveTab <> nil) then
|
||||
TBrowserTab(BrowserTabCtrl.ActiveTab).HandleKEYDOWN(aMessage);
|
||||
end;
|
||||
|
||||
procedure TMainForm.HandleKEYUP(const aMessage : TMsg);
|
||||
begin
|
||||
if (BrowserTabCtrl.ActiveTab <> nil) then
|
||||
TBrowserTab(BrowserTabCtrl.ActiveTab).HandleKEYUP(aMessage);
|
||||
end;
|
||||
|
||||
function TMainForm.HandlePOINTER(const aMessage : TMsg) : boolean;
|
||||
begin
|
||||
Result := (BrowserTabCtrl.ActiveTab <> nil) and
|
||||
TBrowserTab(BrowserTabCtrl.ActiveTab).HandlePOINTER(aMessage);
|
||||
end;
|
||||
|
||||
function TMainForm.PostCustomMessage(aMsg : cardinal; aWParam : WPARAM; aLParam : LPARAM) : boolean;
|
||||
var
|
||||
TempHWND : HWND;
|
||||
begin
|
||||
TempHWND := FmxHandleToHWND(Handle);
|
||||
Result := (TempHWND <> 0) and WinApi.Windows.PostMessage(TempHWND, aMsg, aWParam, aLParam);
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
end.
|
18
demos/Delphi_FMX_Windows/FMXToolBoxBrowser/00-DeleteDCUs.bat
Normal file
18
demos/Delphi_FMX_Windows/FMXToolBoxBrowser/00-DeleteDCUs.bat
Normal 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
|
@ -0,0 +1,63 @@
|
||||
// ************************************************************************
|
||||
// ***************************** 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 FMXToolBoxBrowser;
|
||||
|
||||
uses
|
||||
System.StartUpCopy,
|
||||
FMX.Forms,
|
||||
{$IFDEF MSWINDOWS}
|
||||
WinApi.Windows,
|
||||
{$ENDIF }
|
||||
uCEFApplication,
|
||||
uMainForm in 'uMainForm.pas' {MainForm},
|
||||
uChildForm in 'uChildForm.pas' {ChildForm};
|
||||
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
CreateGlobalCEFApp;
|
||||
|
||||
if GlobalCEFApp.StartMainProcess then
|
||||
begin
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TMainForm, MainForm);
|
||||
Application.Run;
|
||||
end;
|
||||
|
||||
DestroyGlobalCEFApp;
|
||||
end.
|
1297
demos/Delphi_FMX_Windows/FMXToolBoxBrowser/FMXToolBoxBrowser.dproj
Normal file
1297
demos/Delphi_FMX_Windows/FMXToolBoxBrowser/FMXToolBoxBrowser.dproj
Normal file
File diff suppressed because it is too large
Load Diff
468
demos/Delphi_FMX_Windows/FMXToolBoxBrowser/cef.inc
Normal file
468
demos/Delphi_FMX_Windows/FMXToolBoxBrowser/cef.inc
Normal file
@ -0,0 +1,468 @@
|
||||
// ************************************************************************
|
||||
// ***************************** 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}
|
||||
|
||||
// Rad Studio 10.4 - Delphi Sydney
|
||||
{$IFDEF VER340}
|
||||
{$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}
|
||||
{$DEFINE DELPHI27_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF FPC}
|
||||
{$DEFINE SUPPORTS_INLINE}
|
||||
{$IF DEFINED(FPC_FULLVERSION) AND (FPC_FULLVERSION >= 30200)}
|
||||
{$DEFINE FPC_VER_320}
|
||||
{$IFEND}
|
||||
{$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}
|
||||
{$DEFINE DELPHI27_UP}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF DELPHI9_UP}
|
||||
{$DEFINE SUPPORTS_INLINE}
|
||||
{$ENDIF}
|
||||
|
||||
{$IF DEFINED(CPUX32) OR
|
||||
DEFINED(CPU386) OR
|
||||
DEFINED(CPUi386) OR
|
||||
DEFINED(CPUPOWERPC32) OR
|
||||
DEFINED(CPUSPARC32) OR
|
||||
DEFINED(CPU32BITS) OR
|
||||
DEFINED(CPUARM32) OR
|
||||
DEFINED(WIN32) OR
|
||||
DEFINED(IOS32) OR
|
||||
DEFINED(MACOS32) OR
|
||||
DEFINED(LINUX32) OR
|
||||
DEFINED(POSIX32) OR
|
||||
DEFINED(ANDROID32)}
|
||||
{$DEFINE TARGET_32BITS}
|
||||
{$IFEND}
|
||||
|
||||
// Delphi uses MACOS for the new MacOSX and DARWIN is not defined
|
||||
// FPC uses DARWIN for the new MacOSX and MACOS is defined for the classic Macintosh OS (System 7)
|
||||
// We define MACOSX to avoid conflicts in both situations
|
||||
{$IFDEF FPC}
|
||||
{$IFDEF DARWIN}
|
||||
{$DEFINE MACOSX}
|
||||
{$IFEND}
|
||||
{$ELSE}
|
||||
{$IFDEF MACOS}
|
||||
{$DEFINE MACOSX}
|
||||
{$IFEND}
|
||||
{$IFEND}
|
25
demos/Delphi_FMX_Windows/FMXToolBoxBrowser/uChildForm.fmx
Normal file
25
demos/Delphi_FMX_Windows/FMXToolBoxBrowser/uChildForm.fmx
Normal file
@ -0,0 +1,25 @@
|
||||
object ChildForm: TChildForm
|
||||
Left = 0
|
||||
Top = 0
|
||||
Caption = 'Form1'
|
||||
ClientHeight = 600
|
||||
ClientWidth = 800
|
||||
Position = ScreenCenter
|
||||
FormFactor.Width = 320
|
||||
FormFactor.Height = 480
|
||||
FormFactor.Devices = [Desktop]
|
||||
OnCreate = FormCreate
|
||||
OnClose = FormClose
|
||||
OnCloseQuery = FormCloseQuery
|
||||
OnDestroy = FormDestroy
|
||||
OnResize = FormResize
|
||||
OnShow = FormShow
|
||||
DesignerMasterStyle = 0
|
||||
object FMXChromium1: TFMXChromium
|
||||
OnBeforePopup = FMXChromium1BeforePopup
|
||||
OnBeforeClose = FMXChromium1BeforeClose
|
||||
OnClose = FMXChromium1Close
|
||||
Left = 40
|
||||
Top = 32
|
||||
end
|
||||
end
|
402
demos/Delphi_FMX_Windows/FMXToolBoxBrowser/uChildForm.pas
Normal file
402
demos/Delphi_FMX_Windows/FMXToolBoxBrowser/uChildForm.pas
Normal file
@ -0,0 +1,402 @@
|
||||
// ************************************************************************
|
||||
// ***************************** 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 � 2021 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 uChildForm;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
{$IFDEF MSWINDOWS}
|
||||
Winapi.Messages, Winapi.Windows,
|
||||
{$ENDIF}
|
||||
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
|
||||
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
|
||||
uCEFFMXChromium, uCEFFMXWindowParent, uCEFInterfaces, uCEFConstants, uCEFTypes,
|
||||
uCEFChromiumCore;
|
||||
|
||||
type
|
||||
TChildForm = class(TForm)
|
||||
FMXChromium1: TFMXChromium;
|
||||
|
||||
procedure FormShow(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormResize(Sender: TObject);
|
||||
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
||||
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
||||
procedure FormDestroy(Sender: TObject);
|
||||
|
||||
procedure FMXChromium1BeforePopup(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; const popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; var extra_info: ICefDictionaryValue; var noJavascriptAccess, Result: Boolean);
|
||||
procedure FMXChromium1BeforeClose(Sender: TObject; const browser: ICefBrowser);
|
||||
procedure FMXChromium1Close(Sender: TObject; const browser: ICefBrowser; var aAction : TCefCloseBrowserAction);
|
||||
|
||||
protected
|
||||
// Variables to control when can we destroy the form safely
|
||||
FCanClose : boolean; // Set to True in TFMXChromium.OnBeforeClose
|
||||
FClosing : boolean; // Set to True in the CloseQuery event.
|
||||
FMXWindowParent : TFMXWindowParent;
|
||||
FHomepage : string;
|
||||
|
||||
{$IFDEF MSWINDOWS}
|
||||
// This is a workaround for the issue #253
|
||||
// https://github.com/salvadordf/CEF4Delphi/issues/253
|
||||
FCustomWindowState : TWindowState;
|
||||
FOldWndPrc : TFNWndProc;
|
||||
FFormStub : Pointer;
|
||||
{$ENDIF}
|
||||
|
||||
function GetBrowserID : integer;
|
||||
|
||||
procedure ResizeChild;
|
||||
procedure CreateFMXWindowParent;
|
||||
function GetFMXWindowParentRect : System.Types.TRect;
|
||||
function PostCustomMessage(aMsg : cardinal; aWParam : WPARAM = 0; aLParam : LPARAM = 0) : boolean;
|
||||
procedure NotifyMoveOrResizeStarted;
|
||||
|
||||
{$IFDEF MSWINDOWS}
|
||||
function GetCurrentWindowState : TWindowState;
|
||||
procedure UpdateCustomWindowState;
|
||||
procedure CreateHandle; override;
|
||||
procedure DestroyHandle; override;
|
||||
procedure CustomWndProc(var aMessage: TMessage);
|
||||
{$ENDIF}
|
||||
|
||||
public
|
||||
procedure SendCloseMsg;
|
||||
procedure SendShowBrowserMsg;
|
||||
procedure SetBounds(ALeft: Integer; ATop: Integer; AWidth: Integer; AHeight: Integer); override;
|
||||
|
||||
property Closing : boolean read FClosing;
|
||||
property Homepage : string read FHomepage write FHomepage;
|
||||
property BrowserID : integer read GetBrowserID;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.fmx}
|
||||
|
||||
uses
|
||||
FMX.Platform, FMX.Platform.Win,
|
||||
uCEFMiscFunctions, uCEFApplication, uMainForm;
|
||||
|
||||
// Child destruction steps
|
||||
// =======================
|
||||
// 1. FormCloseQuery calls TFMXChromium.CloseBrowser
|
||||
// 2. TFMXChromium.OnClose sends a CEF_DESTROY message to destroy FMXWindowParent in the main thread.
|
||||
// 3. TFMXChromium.OnBeforeClose sets FCanClose := True and sends WM_CLOSE to the form.
|
||||
|
||||
|
||||
function TChildForm.PostCustomMessage(aMsg : cardinal; aWParam : WPARAM; aLParam : LPARAM) : boolean;
|
||||
{$IFDEF MSWINDOWS}
|
||||
var
|
||||
TempHWND : HWND;
|
||||
{$ENDIF}
|
||||
begin
|
||||
Result := False;
|
||||
|
||||
{$IFDEF MSWINDOWS}
|
||||
if (Handle <> nil) then
|
||||
begin
|
||||
TempHWND := FmxHandleToHWND(Handle);
|
||||
Result := (TempHWND <> 0) and WinApi.Windows.PostMessage(TempHWND, aMsg, aWParam, aLParam);
|
||||
end;
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
{$IFDEF MSWINDOWS}
|
||||
procedure TChildForm.CreateHandle;
|
||||
begin
|
||||
inherited CreateHandle;
|
||||
|
||||
FFormStub := MakeObjectInstance(CustomWndProc);
|
||||
FOldWndPrc := TFNWndProc(SetWindowLongPtr(FmxHandleToHWND(Handle), GWLP_WNDPROC, NativeInt(FFormStub)));
|
||||
end;
|
||||
|
||||
procedure TChildForm.DestroyHandle;
|
||||
begin
|
||||
SetWindowLongPtr(FmxHandleToHWND(Handle), GWLP_WNDPROC, NativeInt(FOldWndPrc));
|
||||
FreeObjectInstance(FFormStub);
|
||||
|
||||
inherited DestroyHandle;
|
||||
end;
|
||||
|
||||
procedure TChildForm.CustomWndProc(var aMessage: TMessage);
|
||||
const
|
||||
SWP_STATECHANGED = $8000; // Undocumented
|
||||
var
|
||||
TempWindowPos : PWindowPos;
|
||||
begin
|
||||
try
|
||||
case aMessage.Msg of
|
||||
WM_ENTERMENULOOP :
|
||||
if (aMessage.wParam = 0) and
|
||||
(GlobalCEFApp <> nil) then
|
||||
GlobalCEFApp.OsmodalLoop := True;
|
||||
|
||||
WM_EXITMENULOOP :
|
||||
if (aMessage.wParam = 0) and
|
||||
(GlobalCEFApp <> nil) then
|
||||
GlobalCEFApp.OsmodalLoop := False;
|
||||
|
||||
WM_MOVE,
|
||||
WM_MOVING : NotifyMoveOrResizeStarted;
|
||||
|
||||
WM_SIZE :
|
||||
if (aMessage.wParam = SIZE_RESTORED) then
|
||||
UpdateCustomWindowState;
|
||||
|
||||
WM_WINDOWPOSCHANGING :
|
||||
begin
|
||||
TempWindowPos := TWMWindowPosChanging(aMessage).WindowPos;
|
||||
if ((TempWindowPos.Flags and SWP_STATECHANGED) <> 0) then
|
||||
UpdateCustomWindowState;
|
||||
end;
|
||||
|
||||
WM_SHOWWINDOW :
|
||||
if (aMessage.wParam <> 0) and (aMessage.lParam = SW_PARENTOPENING) then
|
||||
PostCustomMessage(CEF_SHOWBROWSER);
|
||||
|
||||
CEF_DESTROY :
|
||||
if (FMXWindowParent <> nil) then
|
||||
FreeAndNil(FMXWindowParent);
|
||||
|
||||
CEF_SHOWBROWSER :
|
||||
if (FMXWindowParent <> nil) then
|
||||
begin
|
||||
FMXWindowParent.WindowState := TWindowState.wsNormal;
|
||||
FMXWindowParent.Show;
|
||||
FMXWindowParent.SetBounds(GetFMXWindowParentRect);
|
||||
end;
|
||||
end;
|
||||
|
||||
aMessage.Result := CallWindowProc(FOldWndPrc, FmxHandleToHWND(Handle), aMessage.Msg, aMessage.wParam, aMessage.lParam);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TChildForm.CustomWndProc', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TChildForm.UpdateCustomWindowState;
|
||||
var
|
||||
TempNewState : TWindowState;
|
||||
begin
|
||||
TempNewState := GetCurrentWindowState;
|
||||
|
||||
if (FCustomWindowState <> TempNewState) then
|
||||
begin
|
||||
// This is a workaround for the issue #253
|
||||
// https://github.com/salvadordf/CEF4Delphi/issues/253
|
||||
if (FCustomWindowState = TWindowState.wsMinimized) then
|
||||
SendShowBrowserMsg;
|
||||
|
||||
FCustomWindowState := TempNewState;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TChildForm.GetCurrentWindowState : TWindowState;
|
||||
var
|
||||
TempPlacement : TWindowPlacement;
|
||||
TempHWND : HWND;
|
||||
begin
|
||||
// TForm.WindowState is not updated correctly in FMX forms.
|
||||
// We have to call the GetWindowPlacement function in order to read the window state correctly.
|
||||
|
||||
Result := TWindowState.wsNormal;
|
||||
TempHWND := FmxHandleToHWND(Handle);
|
||||
|
||||
ZeroMemory(@TempPlacement, SizeOf(TWindowPlacement));
|
||||
TempPlacement.Length := SizeOf(TWindowPlacement);
|
||||
|
||||
if GetWindowPlacement(TempHWND, @TempPlacement) then
|
||||
case TempPlacement.showCmd of
|
||||
SW_SHOWMAXIMIZED : Result := TWindowState.wsMaximized;
|
||||
SW_SHOWMINIMIZED : Result := TWindowState.wsMinimized;
|
||||
end;
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
function TChildForm.GetBrowserID : integer;
|
||||
begin
|
||||
Result := FMXChromium1.BrowserID;
|
||||
end;
|
||||
|
||||
procedure TChildForm.CreateFMXWindowParent;
|
||||
begin
|
||||
if (FMXWindowParent = nil) then
|
||||
begin
|
||||
FMXWindowParent := TFMXWindowParent.CreateNew(nil);
|
||||
FMXWindowParent.Reparent(Handle);
|
||||
ResizeChild;
|
||||
FMXWindowParent.Show;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TChildForm.GetFMXWindowParentRect : System.Types.TRect;
|
||||
var
|
||||
TempScale : single;
|
||||
begin
|
||||
TempScale := FMXChromium1.ScreenScale;
|
||||
Result.Left := 0;
|
||||
Result.Top := 0;
|
||||
Result.Right := round(ClientWidth * TempScale) - 1;
|
||||
Result.Bottom := round(ClientHeight * TempScale) - 1;
|
||||
end;
|
||||
|
||||
procedure TChildForm.ResizeChild;
|
||||
begin
|
||||
if (FMXWindowParent <> nil) then
|
||||
FMXWindowParent.SetBounds(GetFMXWindowParentRect);
|
||||
end;
|
||||
|
||||
procedure TChildForm.FMXChromium1BeforeClose(Sender: TObject; const browser: ICefBrowser);
|
||||
begin
|
||||
FCanClose := True;
|
||||
SendCloseMsg;
|
||||
end;
|
||||
|
||||
procedure TChildForm.FMXChromium1BeforePopup(Sender: TObject;
|
||||
const browser: ICefBrowser; const frame: ICefFrame; const targetUrl,
|
||||
targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition;
|
||||
userGesture: Boolean; const popupFeatures: TCefPopupFeatures;
|
||||
var windowInfo: TCefWindowInfo; var client: ICefClient;
|
||||
var settings: TCefBrowserSettings; var extra_info: ICefDictionaryValue;
|
||||
var noJavascriptAccess, Result: Boolean);
|
||||
begin
|
||||
// For simplicity, this demo blocks all popup windows and new tabs
|
||||
Result := (targetDisposition in [WOD_NEW_FOREGROUND_TAB, WOD_NEW_BACKGROUND_TAB, WOD_NEW_POPUP, WOD_NEW_WINDOW]);
|
||||
end;
|
||||
|
||||
procedure TChildForm.FMXChromium1Close(Sender: TObject; const browser: ICefBrowser; var aAction : TCefCloseBrowserAction);
|
||||
begin
|
||||
PostCustomMessage(CEF_DESTROY, 0, BrowserID);
|
||||
aAction := cbaDelay;
|
||||
end;
|
||||
|
||||
procedure TChildForm.FormClose(Sender: TObject; var Action: TCloseAction);
|
||||
begin
|
||||
Action := TCloseAction.caFree;
|
||||
end;
|
||||
|
||||
procedure TChildForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
||||
begin
|
||||
CanClose := FCanClose;
|
||||
|
||||
if not(FClosing) then
|
||||
begin
|
||||
FClosing := True;
|
||||
FMXChromium1.CloseBrowser(True);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TChildForm.FormCreate(Sender: TObject);
|
||||
begin
|
||||
FCanClose := False;
|
||||
FClosing := False;
|
||||
FMXWindowParent := nil;
|
||||
FHomepage := '';
|
||||
|
||||
{$IFDEF MSWINDOWS}
|
||||
FCustomWindowState := WindowState;
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
procedure TChildForm.FormDestroy(Sender: TObject);
|
||||
begin
|
||||
// Tell the main form that a child has been destroyed.
|
||||
// The main form will check if this was the last child to close itself
|
||||
if (MainForm <> nil) then MainForm.SendChildDestroyedMsg;
|
||||
end;
|
||||
|
||||
procedure TChildForm.FormResize(Sender: TObject);
|
||||
begin
|
||||
// TFMXWindowParent has to be resized at runtime
|
||||
ResizeChild;
|
||||
end;
|
||||
|
||||
procedure TChildForm.FormShow(Sender: TObject);
|
||||
var
|
||||
TempHandle : HWND;
|
||||
TempRect : System.Types.TRect;
|
||||
TempClientRect : TRectF;
|
||||
begin
|
||||
// TFMXWindowParent has to be created at runtime
|
||||
CreateFMXWindowParent;
|
||||
|
||||
// You *MUST* call CreateBrowser to create and initialize the browser.
|
||||
// This will trigger the AfterCreated event when the browser is fully
|
||||
// initialized and ready to receive commands.
|
||||
|
||||
if not(FMXChromium1.Initialized) then
|
||||
begin
|
||||
TempHandle := FmxHandleToHWND(FMXWindowParent.Handle);
|
||||
TempClientRect := FMXWindowParent.ClientRect;
|
||||
TempRect.Left := round(TempClientRect.Left);
|
||||
TempRect.Top := round(TempClientRect.Top);
|
||||
TempRect.Right := round(TempClientRect.Right);
|
||||
TempRect.Bottom := round(TempClientRect.Bottom);
|
||||
|
||||
FMXChromium1.DefaultUrl := FHomepage;
|
||||
FMXChromium1.CreateBrowser(TempHandle, TempRect);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TChildForm.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 TChildForm.NotifyMoveOrResizeStarted;
|
||||
begin
|
||||
// This is needed to display some HTML elements correctly
|
||||
if (FMXChromium1 <> nil) then FMXChromium1.NotifyMoveOrResizeStarted;
|
||||
end;
|
||||
|
||||
procedure TChildForm.SendCloseMsg;
|
||||
begin
|
||||
PostCustomMessage(WM_CLOSE);
|
||||
end;
|
||||
|
||||
procedure TChildForm.SendShowBrowserMsg;
|
||||
begin
|
||||
PostCustomMessage(CEF_SHOWBROWSER);
|
||||
end;
|
||||
|
||||
end.
|
44
demos/Delphi_FMX_Windows/FMXToolBoxBrowser/uMainForm.fmx
Normal file
44
demos/Delphi_FMX_Windows/FMXToolBoxBrowser/uMainForm.fmx
Normal file
@ -0,0 +1,44 @@
|
||||
object MainForm: TMainForm
|
||||
Left = 0
|
||||
Top = 0
|
||||
BorderIcons = [biSystemMenu, biMinimize]
|
||||
BorderStyle = Single
|
||||
Caption = 'Initializing browser. Please wait...'
|
||||
ClientHeight = 23
|
||||
ClientWidth = 404
|
||||
Position = ScreenCenter
|
||||
FormFactor.Width = 320
|
||||
FormFactor.Height = 480
|
||||
FormFactor.Devices = [Desktop]
|
||||
OnCreate = FormCreate
|
||||
OnCloseQuery = FormCloseQuery
|
||||
OnShow = FormShow
|
||||
DesignerMasterStyle = 0
|
||||
object ButtonPnl: TPanel
|
||||
Align = Client
|
||||
Enabled = False
|
||||
Size.Width = 404.000000000000000000
|
||||
Size.Height = 23.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
TabOrder = 0
|
||||
object AddressEdt: TEdit
|
||||
Touch.InteractiveGestures = [LongTap, DoubleTap]
|
||||
Align = Client
|
||||
TabOrder = 0
|
||||
Text = 'https://www.google.com'
|
||||
Size.Width = 324.000000000000000000
|
||||
Size.Height = 23.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
end
|
||||
object OpenBtn: TButton
|
||||
Align = Right
|
||||
Position.X = 324.000000000000000000
|
||||
Size.Width = 80.000000000000000000
|
||||
Size.Height = 23.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
TabOrder = 1
|
||||
Text = 'Open'
|
||||
OnClick = OpenBtnClick
|
||||
end
|
||||
end
|
||||
end
|
417
demos/Delphi_FMX_Windows/FMXToolBoxBrowser/uMainForm.pas
Normal file
417
demos/Delphi_FMX_Windows/FMXToolBoxBrowser/uMainForm.pas
Normal file
@ -0,0 +1,417 @@
|
||||
// ************************************************************************
|
||||
// ***************************** 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 � 2021 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
|
||||
{$IFDEF MSWINDOWS}
|
||||
Winapi.Messages, Winapi.Windows,
|
||||
{$ENDIF}
|
||||
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
|
||||
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Edit,
|
||||
FMX.Controls.Presentation, FMX.StdCtrls;
|
||||
|
||||
|
||||
const
|
||||
CEF_CHILDDESTROYED = WM_APP + $100;
|
||||
CEF_INITIALIZED = WM_APP + $101;
|
||||
CEF_SHOWBROWSER = WM_APP + $102;
|
||||
|
||||
type
|
||||
TMainForm = class(TForm)
|
||||
ButtonPnl: TPanel;
|
||||
AddressEdt: TEdit;
|
||||
OpenBtn: TButton;
|
||||
procedure FormShow(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
||||
procedure OpenBtnClick(Sender: TObject);
|
||||
private
|
||||
// Variables to control when can we destroy the form safely
|
||||
FCanClose : boolean; // Set to True when all the child forms are closed
|
||||
FClosing : boolean; // Set to True in the CloseQuery event.
|
||||
|
||||
function GetChildFormCount : integer;
|
||||
function GetChildClosing : boolean;
|
||||
|
||||
procedure CreateToolboxChild(const ChildCaption, URL: string);
|
||||
procedure CloseAllChildForms;
|
||||
function PostCustomMessage(aMsg : cardinal; aWParam : WPARAM = 0; aLParam : LPARAM = 0) : boolean;
|
||||
|
||||
protected
|
||||
{$IFDEF MSWINDOWS}
|
||||
// This is a workaround for the issue #253
|
||||
// https://github.com/salvadordf/CEF4Delphi/issues/253
|
||||
FCustomWindowState : TWindowState;
|
||||
FOldWndPrc : TFNWndProc;
|
||||
FFormStub : Pointer;
|
||||
|
||||
function GetCurrentWindowState : TWindowState;
|
||||
procedure UpdateCustomWindowState;
|
||||
procedure CreateHandle; override;
|
||||
procedure DestroyHandle; override;
|
||||
procedure CustomWndProc(var aMessage: TMessage);
|
||||
{$ENDIF}
|
||||
|
||||
public
|
||||
procedure DoCEFInitialized;
|
||||
procedure SendChildDestroyedMsg;
|
||||
|
||||
property ChildClosing : boolean read GetChildClosing;
|
||||
property ChildFormCount : integer read GetChildFormCount;
|
||||
end;
|
||||
|
||||
var
|
||||
MainForm: TMainForm;
|
||||
|
||||
procedure CreateGlobalCEFApp;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.fmx}
|
||||
|
||||
uses
|
||||
FMX.Platform, FMX.Platform.Win,
|
||||
uCEFMiscFunctions, uChildForm, uCEFApplication;
|
||||
|
||||
// This Firemonkey demo shows how to create child windows with browsers using CEF4Delphi.
|
||||
// It uses a custom IFMXApplicationService to handle Windows messages.
|
||||
|
||||
// The application must not try to create browsers before GlobalCEFApp.GlobalContextInitialized
|
||||
// is TRUE, which is set in a different thread when the GlobalCEFApp.OnContextInitialized
|
||||
// event is triggered.
|
||||
// There are several ways to handle the race between the form creation and the
|
||||
// GlobalCEFApp.OnContextInitialized event but this demo is using a simple check
|
||||
// in the TForm.OnShow event.
|
||||
|
||||
// All FMX applications using CEF4Delphi should add the $(FrameworkType) conditional define
|
||||
// in the project options to avoid duplicated resources.
|
||||
// This demo has that define in the menu option :
|
||||
// Project -> Options -> Building -> Delphi compiler -> Conditional defines (All configurations)
|
||||
|
||||
// It's very important to close all the browsers before closing the main form.
|
||||
// Always follow these destruction steps in your applications to avoid
|
||||
// crashes when it's closed. Read the code comments in uChildForm.pas
|
||||
|
||||
// Main form destruction steps
|
||||
// ===========================
|
||||
// 1. Destroy all child forms
|
||||
// 2. Wait until all the child forms are closed before closing the main form and terminating the application.
|
||||
|
||||
|
||||
procedure GlobalCEFApp_OnContextInitialized;
|
||||
begin
|
||||
if (MainForm <> nil) then MainForm.PostCustomMessage(CEF_INITIALIZED);
|
||||
end;
|
||||
|
||||
procedure CreateGlobalCEFApp;
|
||||
begin
|
||||
GlobalCEFApp := TCefApplication.Create;
|
||||
GlobalCEFApp.OnContextInitialized := GlobalCEFApp_OnContextInitialized;
|
||||
end;
|
||||
|
||||
function TMainForm.PostCustomMessage(aMsg : cardinal; aWParam : WPARAM; aLParam : LPARAM) : boolean;
|
||||
{$IFDEF MSWINDOWS}
|
||||
var
|
||||
TempHWND : HWND;
|
||||
{$ENDIF}
|
||||
begin
|
||||
Result := False;
|
||||
|
||||
{$IFDEF MSWINDOWS}
|
||||
if (Handle <> nil) then
|
||||
begin
|
||||
TempHWND := FmxHandleToHWND(Handle);
|
||||
Result := (TempHWND <> 0) and WinApi.Windows.PostMessage(TempHWND, aMsg, aWParam, aLParam);
|
||||
end;
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
{$IFDEF MSWINDOWS}
|
||||
procedure TMainForm.CreateHandle;
|
||||
begin
|
||||
inherited CreateHandle;
|
||||
|
||||
FFormStub := MakeObjectInstance(CustomWndProc);
|
||||
FOldWndPrc := TFNWndProc(SetWindowLongPtr(FmxHandleToHWND(Handle), GWLP_WNDPROC, NativeInt(FFormStub)));
|
||||
end;
|
||||
|
||||
procedure TMainForm.DestroyHandle;
|
||||
begin
|
||||
SetWindowLongPtr(FmxHandleToHWND(Handle), GWLP_WNDPROC, NativeInt(FOldWndPrc));
|
||||
FreeObjectInstance(FFormStub);
|
||||
|
||||
inherited DestroyHandle;
|
||||
end;
|
||||
|
||||
procedure TMainForm.CustomWndProc(var aMessage: TMessage);
|
||||
const
|
||||
SWP_STATECHANGED = $8000; // Undocumented
|
||||
var
|
||||
TempWindowPos : PWindowPos;
|
||||
begin
|
||||
try
|
||||
case aMessage.Msg of
|
||||
WM_ENTERMENULOOP :
|
||||
if (aMessage.wParam = 0) and
|
||||
(GlobalCEFApp <> nil) then
|
||||
GlobalCEFApp.OsmodalLoop := True;
|
||||
|
||||
WM_EXITMENULOOP :
|
||||
if (aMessage.wParam = 0) and
|
||||
(GlobalCEFApp <> nil) then
|
||||
GlobalCEFApp.OsmodalLoop := False;
|
||||
|
||||
WM_SIZE :
|
||||
if (aMessage.wParam = SIZE_RESTORED) then
|
||||
UpdateCustomWindowState;
|
||||
|
||||
WM_WINDOWPOSCHANGING :
|
||||
begin
|
||||
TempWindowPos := TWMWindowPosChanging(aMessage).WindowPos;
|
||||
if ((TempWindowPos.Flags and SWP_STATECHANGED) = SWP_STATECHANGED) then
|
||||
UpdateCustomWindowState;
|
||||
end;
|
||||
|
||||
CEF_CHILDDESTROYED :
|
||||
if FClosing and (ChildFormCount = 0) then
|
||||
begin
|
||||
// If there are no more child forms we can destroy the main form
|
||||
FCanClose := True;
|
||||
PostCustomMessage(WM_CLOSE);
|
||||
end;
|
||||
|
||||
CEF_INITIALIZED : DoCEFInitialized;
|
||||
end;
|
||||
|
||||
aMessage.Result := CallWindowProc(FOldWndPrc, FmxHandleToHWND(Handle), aMessage.Msg, aMessage.wParam, aMessage.lParam);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TMainForm.CustomWndProc', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMainForm.UpdateCustomWindowState;
|
||||
var
|
||||
i : integer;
|
||||
TempNewState : TWindowState;
|
||||
begin
|
||||
TempNewState := GetCurrentWindowState;
|
||||
|
||||
if (FCustomWindowState <> TempNewState) then
|
||||
begin
|
||||
// This is a workaround for the issue #253
|
||||
// https://github.com/salvadordf/CEF4Delphi/issues/253
|
||||
if (FCustomWindowState = TWindowState.wsMinimized) then
|
||||
begin
|
||||
i := 0;
|
||||
|
||||
while (i < screen.FormCount) do
|
||||
begin
|
||||
if (screen.Forms[i] is TChildForm) then
|
||||
TChildForm(screen.Forms[i]).SendShowBrowserMsg;
|
||||
|
||||
inc(i);
|
||||
end;
|
||||
end;
|
||||
|
||||
FCustomWindowState := TempNewState;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TMainForm.GetCurrentWindowState : TWindowState;
|
||||
var
|
||||
TempPlacement : TWindowPlacement;
|
||||
TempHWND : HWND;
|
||||
begin
|
||||
// TForm.WindowState is not updated correctly in FMX forms.
|
||||
// We have to call the GetWindowPlacement function in order to read the window state correctly.
|
||||
|
||||
Result := TWindowState.wsNormal;
|
||||
TempHWND := FmxHandleToHWND(Handle);
|
||||
|
||||
ZeroMemory(@TempPlacement, SizeOf(TWindowPlacement));
|
||||
TempPlacement.Length := SizeOf(TWindowPlacement);
|
||||
|
||||
if GetWindowPlacement(TempHWND, @TempPlacement) then
|
||||
case TempPlacement.showCmd of
|
||||
SW_SHOWMAXIMIZED : Result := TWindowState.wsMaximized;
|
||||
SW_SHOWMINIMIZED : Result := TWindowState.wsMinimized;
|
||||
end;
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
procedure TMainForm.CreateToolboxChild(const ChildCaption, URL: string);
|
||||
var
|
||||
TempChild : TChildForm;
|
||||
begin
|
||||
if (length(URL) > 0) then
|
||||
begin
|
||||
TempChild := TChildForm.Create(self);
|
||||
TempChild.Caption := ChildCaption;
|
||||
TempChild.Homepage := URL;
|
||||
TempChild.Show;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TMainForm.GetChildFormCount : integer;
|
||||
var
|
||||
i : integer;
|
||||
TempComponent : TComponent;
|
||||
begin
|
||||
Result := 0;
|
||||
i := pred(ComponentCount);
|
||||
|
||||
while (i >= 0) do
|
||||
begin
|
||||
TempComponent := Components[i];
|
||||
|
||||
if (TempComponent <> nil) and
|
||||
(TempComponent is TChildForm) then
|
||||
inc(Result);
|
||||
|
||||
dec(i);
|
||||
end;
|
||||
end;
|
||||
|
||||
function TMainForm.GetChildClosing : boolean;
|
||||
var
|
||||
i : integer;
|
||||
TempComponent : TComponent;
|
||||
begin
|
||||
Result := false;
|
||||
i := pred(ComponentCount);
|
||||
|
||||
while (i >= 0) do
|
||||
begin
|
||||
TempComponent := Components[i];
|
||||
|
||||
if (TempComponent <> nil) and
|
||||
(TempComponent is TChildForm) then
|
||||
begin
|
||||
if TChildForm(Components[i]).Closing then
|
||||
begin
|
||||
Result := True;
|
||||
exit;
|
||||
end
|
||||
else
|
||||
dec(i);
|
||||
end
|
||||
else
|
||||
dec(i);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMainForm.OpenBtnClick(Sender: TObject);
|
||||
begin
|
||||
CreateToolboxChild('Browser', AddressEdt.Text);
|
||||
end;
|
||||
|
||||
procedure TMainForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
||||
begin
|
||||
// The main form closes all child forms first and only after that it sets CanClose to True.
|
||||
if FClosing or ChildClosing then
|
||||
CanClose := FCanClose
|
||||
else
|
||||
begin
|
||||
FClosing := True;
|
||||
|
||||
if (ChildFormCount = 0) then
|
||||
CanClose := True
|
||||
else
|
||||
begin
|
||||
CanClose := False;
|
||||
ButtonPnl.Enabled := False;
|
||||
|
||||
CloseAllChildForms;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMainForm.CloseAllChildForms;
|
||||
var
|
||||
i : integer;
|
||||
TempComponent : TComponent;
|
||||
begin
|
||||
i := pred(ComponentCount);
|
||||
|
||||
while (i >= 0) do
|
||||
begin
|
||||
TempComponent := Components[i];
|
||||
|
||||
if (TempComponent <> nil) and
|
||||
(TempComponent is TChildForm) and
|
||||
not(TChildForm(Components[i]).Closing) then
|
||||
TChildForm(Components[i]).SendCloseMsg;
|
||||
|
||||
dec(i);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMainForm.FormCreate(Sender: TObject);
|
||||
begin
|
||||
FCanClose := False;
|
||||
FClosing := False;
|
||||
|
||||
{$IFDEF MSWINDOWS}
|
||||
FCustomWindowState := WindowState;
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
procedure TMainForm.FormShow(Sender: TObject);
|
||||
begin
|
||||
if (GlobalCEFApp <> nil) and GlobalCEFApp.GlobalContextInitialized then DoCEFInitialized;
|
||||
end;
|
||||
|
||||
procedure TMainForm.DoCEFInitialized;
|
||||
begin
|
||||
// Enable the GUI when the global context is initialized.
|
||||
Caption := 'FMX ToolBox Browser';
|
||||
ButtonPnl.Enabled := True;
|
||||
cursor := crDefault;
|
||||
end;
|
||||
|
||||
procedure TMainForm.SendChildDestroyedMsg;
|
||||
begin
|
||||
PostCustomMessage(CEF_CHILDDESTROYED);
|
||||
end;
|
||||
|
||||
end.
|
18
demos/Delphi_FMX_Windows/SimpleFMXBrowser/00-DeleteDCUs.bat
Normal file
18
demos/Delphi_FMX_Windows/SimpleFMXBrowser/00-DeleteDCUs.bat
Normal 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
|
@ -0,0 +1,35 @@
|
||||
program SimpleFMXBrowser;
|
||||
|
||||
uses
|
||||
System.StartUpCopy,
|
||||
FMX.Forms,
|
||||
{$IFDEF MSWINDOWS}
|
||||
WinApi.Windows,
|
||||
{$ENDIF }
|
||||
uCEFApplication,
|
||||
uSimpleFMXBrowser in 'uSimpleFMXBrowser.pas' {SimpleFMXBrowserFrm};
|
||||
|
||||
{$R *.res}
|
||||
|
||||
{$IFDEF MSWINDOWS}
|
||||
// CEF3 needs to set the LARGEADDRESSAWARE flag which allows 32-bit processes to use up to 3GB of RAM.
|
||||
{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE}
|
||||
{$ENDIF}
|
||||
|
||||
begin
|
||||
CreateGlobalCEFApp;
|
||||
|
||||
// You *MUST* call GlobalCEFApp.StartMainProcess in a if..then clause
|
||||
// with the Application initialization inside the begin..end.
|
||||
// Read this https://www.briskbard.com/index.php?lang=en&pageid=cef
|
||||
if GlobalCEFApp.StartMainProcess then
|
||||
begin
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TSimpleFMXBrowserFrm, SimpleFMXBrowserFrm);
|
||||
Application.Run;
|
||||
|
||||
SimpleFMXBrowserFrm.Free;
|
||||
end;
|
||||
|
||||
DestroyGlobalCEFApp;
|
||||
end.
|
1293
demos/Delphi_FMX_Windows/SimpleFMXBrowser/SimpleFMXBrowser.dproj
Normal file
1293
demos/Delphi_FMX_Windows/SimpleFMXBrowser/SimpleFMXBrowser.dproj
Normal file
File diff suppressed because it is too large
Load Diff
468
demos/Delphi_FMX_Windows/SimpleFMXBrowser/cef.inc
Normal file
468
demos/Delphi_FMX_Windows/SimpleFMXBrowser/cef.inc
Normal file
@ -0,0 +1,468 @@
|
||||
// ************************************************************************
|
||||
// ***************************** 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}
|
||||
|
||||
// Rad Studio 10.4 - Delphi Sydney
|
||||
{$IFDEF VER340}
|
||||
{$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}
|
||||
{$DEFINE DELPHI27_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF FPC}
|
||||
{$DEFINE SUPPORTS_INLINE}
|
||||
{$IF DEFINED(FPC_FULLVERSION) AND (FPC_FULLVERSION >= 30200)}
|
||||
{$DEFINE FPC_VER_320}
|
||||
{$IFEND}
|
||||
{$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}
|
||||
{$DEFINE DELPHI27_UP}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF DELPHI9_UP}
|
||||
{$DEFINE SUPPORTS_INLINE}
|
||||
{$ENDIF}
|
||||
|
||||
{$IF DEFINED(CPUX32) OR
|
||||
DEFINED(CPU386) OR
|
||||
DEFINED(CPUi386) OR
|
||||
DEFINED(CPUPOWERPC32) OR
|
||||
DEFINED(CPUSPARC32) OR
|
||||
DEFINED(CPU32BITS) OR
|
||||
DEFINED(CPUARM32) OR
|
||||
DEFINED(WIN32) OR
|
||||
DEFINED(IOS32) OR
|
||||
DEFINED(MACOS32) OR
|
||||
DEFINED(LINUX32) OR
|
||||
DEFINED(POSIX32) OR
|
||||
DEFINED(ANDROID32)}
|
||||
{$DEFINE TARGET_32BITS}
|
||||
{$IFEND}
|
||||
|
||||
// Delphi uses MACOS for the new MacOSX and DARWIN is not defined
|
||||
// FPC uses DARWIN for the new MacOSX and MACOS is defined for the classic Macintosh OS (System 7)
|
||||
// We define MACOSX to avoid conflicts in both situations
|
||||
{$IFDEF FPC}
|
||||
{$IFDEF DARWIN}
|
||||
{$DEFINE MACOSX}
|
||||
{$IFEND}
|
||||
{$ELSE}
|
||||
{$IFDEF MACOS}
|
||||
{$DEFINE MACOSX}
|
||||
{$IFEND}
|
||||
{$IFEND}
|
@ -0,0 +1,91 @@
|
||||
object SimpleFMXBrowserFrm: TSimpleFMXBrowserFrm
|
||||
Left = 0
|
||||
Top = 0
|
||||
Caption = 'Initializing browser. Please wait...'
|
||||
ClientHeight = 600
|
||||
ClientWidth = 1000
|
||||
Position = ScreenCenter
|
||||
FormFactor.Width = 320
|
||||
FormFactor.Height = 480
|
||||
FormFactor.Devices = [Desktop]
|
||||
OnCreate = FormCreate
|
||||
OnCloseQuery = FormCloseQuery
|
||||
OnResize = FormResize
|
||||
OnShow = FormShow
|
||||
DesignerMasterStyle = 0
|
||||
object AddressPnl: TPanel
|
||||
Align = Top
|
||||
Enabled = False
|
||||
Padding.Left = 5.000000000000000000
|
||||
Padding.Top = 5.000000000000000000
|
||||
Padding.Right = 5.000000000000000000
|
||||
Padding.Bottom = 5.000000000000000000
|
||||
Size.Width = 1000.000000000000000000
|
||||
Size.Height = 35.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
TabOrder = 1
|
||||
object AddressEdt: TEdit
|
||||
Touch.InteractiveGestures = [LongTap, DoubleTap]
|
||||
Align = Client
|
||||
TabOrder = 0
|
||||
Text = 'https://www.google.com'
|
||||
Size.Width = 908.000000000000000000
|
||||
Size.Height = 25.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
end
|
||||
object Layout1: TLayout
|
||||
Align = Right
|
||||
Padding.Left = 5.000000000000000000
|
||||
Position.X = 913.000000000000000000
|
||||
Position.Y = 5.000000000000000000
|
||||
Size.Width = 82.000000000000000000
|
||||
Size.Height = 25.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
TabOrder = 3
|
||||
object GoBtn: TButton
|
||||
Align = Left
|
||||
Position.X = 5.000000000000000000
|
||||
Size.Width = 36.000000000000000000
|
||||
Size.Height = 25.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
TabOrder = 0
|
||||
Text = 'Go'
|
||||
OnClick = GoBtnClick
|
||||
end
|
||||
object SnapShotBtn: TButton
|
||||
Align = Right
|
||||
StyledSettings = [Style, FontColor]
|
||||
Position.X = 46.000000000000000000
|
||||
Size.Width = 36.000000000000000000
|
||||
Size.Height = 25.000000000000000000
|
||||
Size.PlatformDefault = False
|
||||
TabOrder = 2
|
||||
Text = #181
|
||||
TextSettings.Font.Family = 'Webdings'
|
||||
TextSettings.Font.Size = 24.000000000000000000
|
||||
OnClick = SnapShotBtnClick
|
||||
end
|
||||
end
|
||||
end
|
||||
object Timer1: TTimer
|
||||
Enabled = False
|
||||
Interval = 300
|
||||
OnTimer = Timer1Timer
|
||||
Left = 40
|
||||
Top = 129
|
||||
end
|
||||
object SaveDialog1: TSaveDialog
|
||||
Left = 40
|
||||
Top = 192
|
||||
end
|
||||
object FMXChromium1: TFMXChromium
|
||||
OnBeforeContextMenu = FMXChromium1BeforeContextMenu
|
||||
OnContextMenuCommand = FMXChromium1ContextMenuCommand
|
||||
OnBeforePopup = FMXChromium1BeforePopup
|
||||
OnAfterCreated = FMXChromium1AfterCreated
|
||||
OnBeforeClose = FMXChromium1BeforeClose
|
||||
OnClose = FMXChromium1Close
|
||||
Left = 40
|
||||
Top = 65
|
||||
end
|
||||
end
|
523
demos/Delphi_FMX_Windows/SimpleFMXBrowser/uSimpleFMXBrowser.pas
Normal file
523
demos/Delphi_FMX_Windows/SimpleFMXBrowser/uSimpleFMXBrowser.pas
Normal file
@ -0,0 +1,523 @@
|
||||
// ************************************************************************
|
||||
// ***************************** 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 � 2021 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 uSimpleFMXBrowser;
|
||||
|
||||
{$I cef.inc}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
{$IFDEF MSWINDOWS}
|
||||
Winapi.Messages, Winapi.Windows,
|
||||
{$ENDIF}
|
||||
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
|
||||
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls,
|
||||
FMX.Edit, FMX.Controls.Presentation, uCEFFMXWindowParent, uCEFFMXChromium,
|
||||
System.SyncObjs,
|
||||
uCEFInterfaces, uCEFConstants, uCEFTypes, uCEFChromiumCore, FMX.Layouts;
|
||||
|
||||
const
|
||||
MINIBROWSER_CONTEXTMENU_SHOWDEVTOOLS = MENU_ID_USER_FIRST + 1;
|
||||
|
||||
CEF_SHOWBROWSER = WM_APP + $101;
|
||||
|
||||
type
|
||||
TSimpleFMXBrowserFrm = class(TForm)
|
||||
AddressPnl: TPanel;
|
||||
AddressEdt: TEdit;
|
||||
FMXChromium1: TFMXChromium;
|
||||
Timer1: TTimer;
|
||||
SaveDialog1: TSaveDialog;
|
||||
Layout1: TLayout;
|
||||
GoBtn: TButton;
|
||||
SnapShotBtn: TButton;
|
||||
|
||||
procedure GoBtnClick(Sender: TObject);
|
||||
procedure Timer1Timer(Sender: TObject);
|
||||
procedure SnapShotBtnClick(Sender: TObject);
|
||||
|
||||
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormShow(Sender: TObject);
|
||||
procedure FormResize(Sender: TObject);
|
||||
|
||||
procedure FMXChromium1Close(Sender: TObject; const browser: ICefBrowser; var aAction : TCefCloseBrowserAction);
|
||||
procedure FMXChromium1BeforeClose(Sender: TObject; const browser: ICefBrowser);
|
||||
procedure FMXChromium1BeforePopup(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl, targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; const popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo; var client: ICefClient; var settings: TCefBrowserSettings; var extra_info: ICefDictionaryValue; var noJavascriptAccess, Result: Boolean);
|
||||
procedure FMXChromium1AfterCreated(Sender: TObject; const browser: ICefBrowser);
|
||||
procedure FMXChromium1BeforeContextMenu(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const params: ICefContextMenuParams; const model: ICefMenuModel);
|
||||
procedure FMXChromium1ContextMenuCommand(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const params: ICefContextMenuParams; commandId: Integer; eventFlags: Cardinal; out Result: Boolean);
|
||||
|
||||
protected
|
||||
// Variables to control when can we destroy the form safely
|
||||
FCanClose : boolean; // Set to True in TFMXChromium.OnBeforeClose
|
||||
FClosing : boolean; // Set to True in the CloseQuery event.
|
||||
|
||||
FMXWindowParent : TFMXWindowParent;
|
||||
|
||||
{$IFDEF MSWINDOWS}
|
||||
// This is a workaround for the issue #253
|
||||
// https://github.com/salvadordf/CEF4Delphi/issues/253
|
||||
FCustomWindowState : TWindowState;
|
||||
FOldWndPrc : TFNWndProc;
|
||||
FFormStub : Pointer;
|
||||
{$ENDIF}
|
||||
|
||||
procedure LoadURL;
|
||||
procedure ResizeChild;
|
||||
procedure CreateFMXWindowParent;
|
||||
function GetFMXWindowParentRect : System.Types.TRect;
|
||||
function PostCustomMessage(aMsg : cardinal; aWParam : WPARAM = 0; aLParam : LPARAM = 0) : boolean;
|
||||
|
||||
{$IFDEF MSWINDOWS}
|
||||
function GetCurrentWindowState : TWindowState;
|
||||
procedure UpdateCustomWindowState;
|
||||
procedure CreateHandle; override;
|
||||
procedure DestroyHandle; override;
|
||||
procedure CustomWndProc(var aMessage: TMessage);
|
||||
{$ENDIF}
|
||||
|
||||
public
|
||||
procedure NotifyMoveOrResizeStarted;
|
||||
procedure SetBounds(ALeft: Integer; ATop: Integer; AWidth: Integer; AHeight: Integer); override;
|
||||
end;
|
||||
|
||||
var
|
||||
SimpleFMXBrowserFrm: TSimpleFMXBrowserFrm;
|
||||
|
||||
procedure CreateGlobalCEFApp;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.fmx}
|
||||
|
||||
// This is a demo with the simplest web browser you can build using CEF4Delphi
|
||||
// with FMX components and it doesn't show any sign of progress like other web browsers do.
|
||||
|
||||
// Remember that it may take a few seconds to load if Windows update, your antivirus or
|
||||
// any other windows service is using your hard drive.
|
||||
|
||||
// Depending on your internet connection it may take longer than expected.
|
||||
|
||||
// Please check that your firewall or antivirus are not blocking this application
|
||||
// or the domain "google.com". If you don't live in the US, you'll be redirected to
|
||||
// another domain which will take a little time too.
|
||||
|
||||
// This demo uses a TFMXChromium and a TFMXWindowParent. It replaces the original WndProc with a
|
||||
// custom CustomWndProc procedure to handle Windows messages.
|
||||
|
||||
// All FMX applications using CEF4Delphi should add the $(FrameworkType) conditional define
|
||||
// in the project options to avoid duplicated resources.
|
||||
// This demo has that define in the menu option :
|
||||
// Project -> Options -> Building -> Delphi compiler -> Conditional defines (All configurations)
|
||||
|
||||
// Destruction steps
|
||||
// =================
|
||||
// 1. FormCloseQuery sets CanClose to FALSE calls TFMXChromium.CloseBrowser which triggers the TFMXChromium.OnClose event.
|
||||
// 2. TFMXChromium.OnClose sends a CEFBROWSER_DESTROY message to destroy CEFWindowParent1 in the main thread, which triggers the TFMXChromium.OnBeforeClose event.
|
||||
// 3. TFMXChromium.OnBeforeClose sets FCanClose := True and sends WM_CLOSE to the form.
|
||||
|
||||
uses
|
||||
FMX.Platform, FMX.Platform.Win,
|
||||
uCEFMiscFunctions, uCEFApplication;
|
||||
|
||||
procedure CreateGlobalCEFApp;
|
||||
begin
|
||||
GlobalCEFApp := TCefApplication.Create;
|
||||
//GlobalCEFApp.LogFile := 'cef.log';
|
||||
//GlobalCEFApp.LogSeverity := LOGSEVERITY_VERBOSE;
|
||||
|
||||
// In case you want to use custom directories for the CEF binaries, cache and user data.
|
||||
// If you don't set a cache directory the browser will use in-memory cache.
|
||||
{
|
||||
GlobalCEFApp.FrameworkDirPath := 'cef';
|
||||
GlobalCEFApp.ResourcesDirPath := 'cef';
|
||||
GlobalCEFApp.LocalesDirPath := 'cef\locales';
|
||||
GlobalCEFApp.EnableGPU := True; // Enable hardware acceleration
|
||||
GlobalCEFApp.cache := 'cef\cache';
|
||||
GlobalCEFApp.UserDataPath := 'cef\User Data';
|
||||
}
|
||||
end;
|
||||
|
||||
procedure TSimpleFMXBrowserFrm.FMXChromium1AfterCreated(Sender: TObject;
|
||||
const browser: ICefBrowser);
|
||||
begin
|
||||
// Now the browser is fully initialized we can send a message to the main form to load the initial web page.
|
||||
PostCustomMessage(CEF_AFTERCREATED);
|
||||
end;
|
||||
|
||||
procedure TSimpleFMXBrowserFrm.FMXChromium1BeforeClose(Sender: TObject; const browser: ICefBrowser);
|
||||
begin
|
||||
FCanClose := True;
|
||||
PostCustomMessage(WM_CLOSE);
|
||||
end;
|
||||
|
||||
procedure TSimpleFMXBrowserFrm.FMXChromium1BeforeContextMenu(
|
||||
Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame;
|
||||
const params: ICefContextMenuParams; const model: ICefMenuModel);
|
||||
begin
|
||||
model.AddItem(MINIBROWSER_CONTEXTMENU_SHOWDEVTOOLS, 'Show DevTools');
|
||||
end;
|
||||
|
||||
procedure TSimpleFMXBrowserFrm.FMXChromium1BeforePopup( Sender : TObject;
|
||||
const browser : ICefBrowser;
|
||||
const frame : ICefFrame;
|
||||
const targetUrl : ustring;
|
||||
const targetFrameName : ustring;
|
||||
targetDisposition : TCefWindowOpenDisposition;
|
||||
userGesture : Boolean;
|
||||
const popupFeatures : TCefPopupFeatures;
|
||||
var windowInfo : TCefWindowInfo;
|
||||
var client : ICefClient;
|
||||
var settings : TCefBrowserSettings;
|
||||
var extra_info : ICefDictionaryValue;
|
||||
var noJavascriptAccess : boolean;
|
||||
var Result : boolean);
|
||||
begin
|
||||
// For simplicity, this demo blocks all popup windows and new tabs
|
||||
Result := (targetDisposition in [WOD_NEW_FOREGROUND_TAB, WOD_NEW_BACKGROUND_TAB, WOD_NEW_POPUP, WOD_NEW_WINDOW]);
|
||||
end;
|
||||
|
||||
procedure TSimpleFMXBrowserFrm.FMXChromium1Close(Sender: TObject; const browser: ICefBrowser; var aAction : TCefCloseBrowserAction);
|
||||
begin
|
||||
PostCustomMessage(CEF_DESTROY);
|
||||
aAction := cbaDelay;
|
||||
end;
|
||||
|
||||
procedure TSimpleFMXBrowserFrm.FMXChromium1ContextMenuCommand(
|
||||
Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame;
|
||||
const params: ICefContextMenuParams; commandId: Integer;
|
||||
eventFlags: Cardinal; out Result: Boolean);
|
||||
var
|
||||
TempPoint : TPoint;
|
||||
begin
|
||||
if (commandId = MINIBROWSER_CONTEXTMENU_SHOWDEVTOOLS) then
|
||||
begin
|
||||
TempPoint.x := params.XCoord;
|
||||
TempPoint.y := params.YCoord;
|
||||
|
||||
FMXChromium1.ShowDevTools(TempPoint);
|
||||
end;
|
||||
end;
|
||||
|
||||
function TSimpleFMXBrowserFrm.PostCustomMessage(aMsg : cardinal; aWParam : WPARAM; aLParam : LPARAM) : boolean;
|
||||
{$IFDEF MSWINDOWS}
|
||||
var
|
||||
TempHWND : HWND;
|
||||
{$ENDIF}
|
||||
begin
|
||||
{$IFDEF MSWINDOWS}
|
||||
TempHWND := FmxHandleToHWND(Handle);
|
||||
Result := (TempHWND <> 0) and WinApi.Windows.PostMessage(TempHWND, aMsg, aWParam, aLParam);
|
||||
{$ELSE}
|
||||
Result := False;
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
{$IFDEF MSWINDOWS}
|
||||
procedure TSimpleFMXBrowserFrm.CreateHandle;
|
||||
begin
|
||||
inherited CreateHandle;
|
||||
|
||||
FFormStub := MakeObjectInstance(CustomWndProc);
|
||||
FOldWndPrc := TFNWndProc(SetWindowLongPtr(FmxHandleToHWND(Handle), GWLP_WNDPROC, NativeInt(FFormStub)));
|
||||
end;
|
||||
|
||||
procedure TSimpleFMXBrowserFrm.DestroyHandle;
|
||||
begin
|
||||
SetWindowLongPtr(FmxHandleToHWND(Handle), GWLP_WNDPROC, NativeInt(FOldWndPrc));
|
||||
FreeObjectInstance(FFormStub);
|
||||
|
||||
inherited DestroyHandle;
|
||||
end;
|
||||
|
||||
procedure TSimpleFMXBrowserFrm.CustomWndProc(var aMessage: TMessage);
|
||||
const
|
||||
SWP_STATECHANGED = $8000; // Undocumented
|
||||
var
|
||||
TempWindowPos : PWindowPos;
|
||||
begin
|
||||
try
|
||||
case aMessage.Msg of
|
||||
WM_ENTERMENULOOP :
|
||||
if (aMessage.wParam = 0) and
|
||||
(GlobalCEFApp <> nil) then
|
||||
GlobalCEFApp.OsmodalLoop := True;
|
||||
|
||||
WM_EXITMENULOOP :
|
||||
if (aMessage.wParam = 0) and
|
||||
(GlobalCEFApp <> nil) then
|
||||
GlobalCEFApp.OsmodalLoop := False;
|
||||
|
||||
WM_MOVE,
|
||||
WM_MOVING : NotifyMoveOrResizeStarted;
|
||||
|
||||
WM_SIZE :
|
||||
if (aMessage.wParam = SIZE_RESTORED) then
|
||||
UpdateCustomWindowState;
|
||||
|
||||
WM_WINDOWPOSCHANGING :
|
||||
begin
|
||||
TempWindowPos := TWMWindowPosChanging(aMessage).WindowPos;
|
||||
if ((TempWindowPos.Flags and SWP_STATECHANGED) <> 0) then
|
||||
UpdateCustomWindowState;
|
||||
end;
|
||||
|
||||
WM_SHOWWINDOW :
|
||||
if (aMessage.wParam <> 0) and (aMessage.lParam = SW_PARENTOPENING) then
|
||||
PostCustomMessage(CEF_SHOWBROWSER);
|
||||
|
||||
CEF_AFTERCREATED :
|
||||
begin
|
||||
Caption := 'Simple FMX Browser';
|
||||
AddressPnl.Enabled := True;
|
||||
end;
|
||||
|
||||
CEF_DESTROY :
|
||||
if (FMXWindowParent <> nil) then
|
||||
FreeAndNil(FMXWindowParent);
|
||||
|
||||
CEF_SHOWBROWSER :
|
||||
if (FMXWindowParent <> nil) then
|
||||
begin
|
||||
FMXWindowParent.WindowState := TWindowState.wsNormal;
|
||||
FMXWindowParent.Show;
|
||||
FMXWindowParent.SetBounds(GetFMXWindowParentRect);
|
||||
end;
|
||||
end;
|
||||
|
||||
aMessage.Result := CallWindowProc(FOldWndPrc, FmxHandleToHWND(Handle), aMessage.Msg, aMessage.wParam, aMessage.lParam);
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TSimpleFMXBrowserFrm.CustomWndProc', e) then raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSimpleFMXBrowserFrm.UpdateCustomWindowState;
|
||||
var
|
||||
TempNewState : TWindowState;
|
||||
begin
|
||||
TempNewState := GetCurrentWindowState;
|
||||
|
||||
if (FCustomWindowState <> TempNewState) then
|
||||
begin
|
||||
// This is a workaround for the issue #253
|
||||
// https://github.com/salvadordf/CEF4Delphi/issues/253
|
||||
if (FCustomWindowState = TWindowState.wsMinimized) then
|
||||
PostCustomMessage(CEF_SHOWBROWSER);
|
||||
|
||||
FCustomWindowState := TempNewState;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TSimpleFMXBrowserFrm.GetCurrentWindowState : TWindowState;
|
||||
var
|
||||
TempPlacement : TWindowPlacement;
|
||||
TempHWND : HWND;
|
||||
begin
|
||||
// TForm.WindowState is not updated correctly in FMX forms.
|
||||
// We have to call the GetWindowPlacement function in order to read the window state correctly.
|
||||
|
||||
Result := TWindowState.wsNormal;
|
||||
TempHWND := FmxHandleToHWND(Handle);
|
||||
|
||||
ZeroMemory(@TempPlacement, SizeOf(TWindowPlacement));
|
||||
TempPlacement.Length := SizeOf(TWindowPlacement);
|
||||
|
||||
if GetWindowPlacement(TempHWND, @TempPlacement) then
|
||||
case TempPlacement.showCmd of
|
||||
SW_SHOWMAXIMIZED : Result := TWindowState.wsMaximized;
|
||||
SW_SHOWMINIMIZED : Result := TWindowState.wsMinimized;
|
||||
end;
|
||||
|
||||
if IsIconic(TempHWND) then Result := TWindowState.wsMinimized;
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
procedure TSimpleFMXBrowserFrm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
||||
begin
|
||||
CanClose := FCanClose;
|
||||
|
||||
if not(FClosing) then
|
||||
begin
|
||||
FClosing := True;
|
||||
Visible := False;
|
||||
FMXChromium1.CloseBrowser(True);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSimpleFMXBrowserFrm.FormCreate(Sender: TObject);
|
||||
begin
|
||||
FCanClose := False;
|
||||
FClosing := False;
|
||||
FMXWindowParent := nil;
|
||||
|
||||
{$IFDEF MSWINDOWS}
|
||||
FCustomWindowState := WindowState;
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
procedure TSimpleFMXBrowserFrm.FormResize(Sender: TObject);
|
||||
begin
|
||||
// TFMXWindowParent has to be resized at runtime
|
||||
ResizeChild;
|
||||
end;
|
||||
|
||||
function TSimpleFMXBrowserFrm.GetFMXWindowParentRect : System.Types.TRect;
|
||||
var
|
||||
TempScale : single;
|
||||
begin
|
||||
TempScale := FMXChromium1.ScreenScale;
|
||||
Result.Left := 0;
|
||||
Result.Top := round(AddressPnl.Height * TempScale);
|
||||
Result.Right := round(ClientWidth * TempScale) - 1;
|
||||
Result.Bottom := round(ClientHeight * TempScale) - 1;
|
||||
end;
|
||||
|
||||
procedure TSimpleFMXBrowserFrm.ResizeChild;
|
||||
begin
|
||||
if (FMXWindowParent <> nil) then
|
||||
FMXWindowParent.SetBounds(GetFMXWindowParentRect);
|
||||
end;
|
||||
|
||||
procedure TSimpleFMXBrowserFrm.SnapShotBtnClick(Sender: TObject);
|
||||
var
|
||||
TempBitmap : TBitmap;
|
||||
begin
|
||||
TempBitmap := nil;
|
||||
|
||||
try
|
||||
SaveDialog1.DefaultExt := 'bmp';
|
||||
SaveDialog1.Filter := 'Bitmap files (*.bmp)|*.BMP';
|
||||
|
||||
if SaveDialog1.Execute and (length(SaveDialog1.FileName) > 0) then
|
||||
begin
|
||||
TempBitmap := TBitmap.Create;
|
||||
|
||||
if FMXChromium1.TakeSnapshot(TempBitmap, GetFMXWindowParentRect) then
|
||||
TempBitmap.SaveToFile(SaveDialog1.FileName);
|
||||
end;
|
||||
finally
|
||||
if (TempBitmap <> nil) then FreeAndNil(TempBitmap);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSimpleFMXBrowserFrm.CreateFMXWindowParent;
|
||||
begin
|
||||
if (FMXWindowParent = nil) then
|
||||
begin
|
||||
FMXWindowParent := TFMXWindowParent.CreateNew(nil);
|
||||
FMXWindowParent.Reparent(Handle);
|
||||
ResizeChild;
|
||||
FMXWindowParent.Show;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSimpleFMXBrowserFrm.FormShow(Sender: TObject);
|
||||
var
|
||||
TempHandle : HWND;
|
||||
TempRect : System.Types.TRect;
|
||||
TempClientRect : TRectF;
|
||||
begin
|
||||
// TFMXWindowParent has to be created at runtime
|
||||
CreateFMXWindowParent;
|
||||
|
||||
// You *MUST* call CreateBrowser to create and initialize the browser.
|
||||
// This will trigger the AfterCreated event when the browser is fully
|
||||
// initialized and ready to receive commands.
|
||||
|
||||
// GlobalCEFApp.GlobalContextInitialized has to be TRUE before creating any browser
|
||||
// If it's not initialized yet, we use a simple timer to create the browser later.
|
||||
if not(FMXChromium1.Initialized) then
|
||||
begin
|
||||
TempHandle := FmxHandleToHWND(FMXWindowParent.Handle);
|
||||
TempClientRect := FMXWindowParent.ClientRect;
|
||||
TempRect.Left := round(TempClientRect.Left);
|
||||
TempRect.Top := round(TempClientRect.Top);
|
||||
TempRect.Right := round(TempClientRect.Right);
|
||||
TempRect.Bottom := round(TempClientRect.Bottom);
|
||||
|
||||
FMXChromium1.DefaultUrl := AddressEdt.Text;
|
||||
if not(FMXChromium1.CreateBrowser(TempHandle, TempRect)) then Timer1.Enabled := True;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSimpleFMXBrowserFrm.GoBtnClick(Sender: TObject);
|
||||
begin
|
||||
LoadURL;
|
||||
end;
|
||||
|
||||
procedure TSimpleFMXBrowserFrm.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 TSimpleFMXBrowserFrm.NotifyMoveOrResizeStarted;
|
||||
begin
|
||||
if (FMXChromium1 <> nil) then FMXChromium1.NotifyMoveOrResizeStarted;
|
||||
end;
|
||||
|
||||
procedure TSimpleFMXBrowserFrm.Timer1Timer(Sender: TObject);
|
||||
var
|
||||
TempHandle : HWND;
|
||||
TempRect : System.Types.TRect;
|
||||
TempClientRect : TRectF;
|
||||
begin
|
||||
Timer1.Enabled := False;
|
||||
TempHandle := FmxHandleToHWND(FMXWindowParent.Handle);
|
||||
TempClientRect := FMXWindowParent.ClientRect;
|
||||
TempRect.Left := round(TempClientRect.Left);
|
||||
TempRect.Top := round(TempClientRect.Top);
|
||||
TempRect.Right := round(TempClientRect.Right);
|
||||
TempRect.Bottom := round(TempClientRect.Bottom);
|
||||
|
||||
if not(FMXChromium1.CreateBrowser(TempHandle, TempRect)) and not(FMXChromium1.Initialized) then
|
||||
Timer1.Enabled := True;
|
||||
end;
|
||||
|
||||
procedure TSimpleFMXBrowserFrm.LoadURL;
|
||||
begin
|
||||
FMXChromium1.LoadURL(AddressEdt.Text);
|
||||
end;
|
||||
|
||||
end.
|
Reference in New Issue
Block a user