diff --git a/demos/Delphi_VCL/TabbedBrowser2/00-DeleteDCUs.bat b/demos/Delphi_VCL/TabbedBrowser2/00-DeleteDCUs.bat new file mode 100644 index 00000000..a9a84095 --- /dev/null +++ b/demos/Delphi_VCL/TabbedBrowser2/00-DeleteDCUs.bat @@ -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 diff --git a/demos/Delphi_VCL/TabbedBrowser2/TabbedBrowser2.dpr b/demos/Delphi_VCL/TabbedBrowser2/TabbedBrowser2.dpr new file mode 100644 index 00000000..4e9a20ab --- /dev/null +++ b/demos/Delphi_VCL/TabbedBrowser2/TabbedBrowser2.dpr @@ -0,0 +1,75 @@ +// ************************************************************************ +// ***************************** 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 + * 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 TabbedBrowser2; + +{$I cef.inc} + +uses + {$IFDEF DELPHI16_UP} + WinApi.Windows, + Vcl.Forms, + {$ELSE} + Forms, + Windows, + {$ENDIF} + uCEFApplication, + uMainForm in 'uMainForm.pas' {MainForm}, + uBrowserFrame in 'uBrowserFrame.pas' {BrowserFrame: TFrame}, + uBrowserTab in 'uBrowserTab.pas'; + +{$R *.res} + +// CEF needs to set the LARGEADDRESSAWARE flag which allows 32-bit processes to use up to 3GB of RAM. +// If you don't add this flag the rederer process will crash when you try to load large images. +{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE} + +begin + CreateGlobalCEFApp; + + if GlobalCEFApp.StartMainProcess then + begin + Application.Initialize; + {$IFDEF DELPHI11_UP} + Application.MainFormOnTaskbar := True; + {$ENDIF} + Application.CreateForm(TMainForm, MainForm); + Application.Run; + end; + + DestroyGlobalCEFApp; +end. diff --git a/demos/Delphi_VCL/TabbedBrowser2/TabbedBrowser2.dproj b/demos/Delphi_VCL/TabbedBrowser2/TabbedBrowser2.dproj new file mode 100644 index 00000000..c6a0dab1 --- /dev/null +++ b/demos/Delphi_VCL/TabbedBrowser2/TabbedBrowser2.dproj @@ -0,0 +1,983 @@ + + + {2A491C1D-D0F3-4D4B-9606-F7FC09C7713E} + 18.8 + VCL + TabbedBrowser2.dpr + True + Debug + Win32 + 1 + Application + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_1 + true + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + .\$(Platform)\$(Config) + ..\..\..\bin + false + false + false + false + false + System;Xml;Data;Datasnap;Web;Soap;Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;$(DCC_Namespace) + $(BDS)\bin\delphi_PROJECTICON.ico + $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png + $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png + TabbedBrowser2 + 3082 + CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= + + + DBXSqliteDriver;bindcompdbx;fmxase;DBXDb2Driver;DBXInterBaseDriver;vcl;DBXSybaseASEDriver;vclactnband;RESTComponents;vclFireDAC;IndyProtocols250;FireDACDb2Driver;IndyCore250;DataSnapFireDAC;svnui;tethering;dsnapcon;FireDACADSDriver;FireDACMSAccDriver;fmxFireDAC;DBXMSSQLDriver;vclimg;FireDACInfxDriver;DatasnapConnectorsFreePascal;FireDAC;FireDACMSSQLDriver;vcltouch;Componentes_UI;vcldb;bindcompfmx;svn;Detours;FireDACSqliteDriver;FireDACPgDriver;DBXOracleDriver;inetdb;FireDACASADriver;DBXOdbcDriver;FireDACTDataDriver;SVGPackage;soaprtl;DbxCommonDriver;FireDACIBDriver;fmx;DataSnapServer;xmlrtl;soapmidas;DataSnapNativeClient;fmxobj;fmxdae;vclwinx;rtl;FireDACDSDriver;DbxClientDriver;DBXSybaseASADriver;CustomIPTransport;vcldsnap;dbexpress;FireDACDBXDriver;vclx;bindcomp;appanalytics;dsnap;DataSnapCommon;DBXInformixDriver;FireDACCommon;bindcompvcl;RESTBackendComponents;DataSnapConnectors;VCLRESTComponents;soapserver;dbxcds;VclSmp;adortl;FireDACODBCDriver;DataSnapIndy10ServerTransport;vclie;CEF4Delphi_FMX;bindengine;DBXMySQLDriver;FireDACOracleDriver;dsnapxml;FireDACMySQLDriver;dbrtl;inetdbxpress;DBXFirebirdDriver;DataSnapProviderClient;FireDACMongoDBDriver;FireDACCommonODBC;FireDACCommonDriver;CloudService;DataSnapClient;VisualStyles;IndySystem250;inet;DataSnapServerMidas;$(DCC_UsePackage) + Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) + Debug + true + CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= + 1033 + $(BDS)\bin\default_app.manifest + + + DBXSqliteDriver;bindcompdbx;fmxase;DBXDb2Driver;DBXInterBaseDriver;vcl;DBXSybaseASEDriver;vclactnband;RESTComponents;vclFireDAC;IndyProtocols250;FireDACDb2Driver;IndyCore250;DataSnapFireDAC;tethering;dsnapcon;FireDACADSDriver;FireDACMSAccDriver;fmxFireDAC;DBXMSSQLDriver;vclimg;FireDACInfxDriver;DatasnapConnectorsFreePascal;FireDAC;FireDACMSSQLDriver;vcltouch;vcldb;bindcompfmx;FireDACSqliteDriver;FireDACPgDriver;DBXOracleDriver;inetdb;FireDACASADriver;DBXOdbcDriver;FireDACTDataDriver;soaprtl;DbxCommonDriver;FireDACIBDriver;fmx;DataSnapServer;xmlrtl;soapmidas;DataSnapNativeClient;fmxobj;fmxdae;vclwinx;rtl;FireDACDSDriver;DbxClientDriver;DBXSybaseASADriver;CustomIPTransport;vcldsnap;dbexpress;FireDACDBXDriver;vclx;bindcomp;appanalytics;dsnap;DataSnapCommon;DBXInformixDriver;FireDACCommon;bindcompvcl;RESTBackendComponents;DataSnapConnectors;VCLRESTComponents;soapserver;dbxcds;VclSmp;adortl;FireDACODBCDriver;DataSnapIndy10ServerTransport;vclie;CEF4Delphi_FMX;bindengine;DBXMySQLDriver;FireDACOracleDriver;dsnapxml;FireDACMySQLDriver;dbrtl;inetdbxpress;DBXFirebirdDriver;DataSnapProviderClient;FireDACMongoDBDriver;FireDACCommonODBC;FireDACCommonDriver;CloudService;DataSnapClient;IndySystem250;inet;DataSnapServerMidas;$(DCC_UsePackage) + + + DEBUG;$(DCC_Define) + true + false + true + true + true + + + false + true + PerMonitorV2 + true + 1033 + + + false + RELEASE;$(DCC_Define) + 0 + 0 + + + true + PerMonitorV2 + + + + MainSource + + +
MainForm
+
+ +
BrowserFrame
+ TFrame +
+ + + Cfg_2 + Base + + + Base + + + Cfg_1 + Base + +
+ + Delphi.Personality.12 + Application + + + + TabbedBrowser2.dpr + + + IP Abstraction Indy Implementation Design Time + Microsoft Office 2000 Sample Automation Server Wrapper Components + Microsoft Office XP Sample Automation Server Wrapper Components + + + + + + TabbedBrowser2.exe + true + + + + + 1 + + + Contents\MacOS + 1 + + + 0 + + + + + classes + 1 + + + classes + 1 + + + + + res\xml + 1 + + + res\xml + 1 + + + + + library\lib\armeabi-v7a + 1 + + + + + library\lib\armeabi + 1 + + + library\lib\armeabi + 1 + + + + + library\lib\armeabi-v7a + 1 + + + + + library\lib\mips + 1 + + + library\lib\mips + 1 + + + + + library\lib\armeabi-v7a + 1 + + + library\lib\arm64-v8a + 1 + + + + + library\lib\armeabi-v7a + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\values + 1 + + + res\values + 1 + + + + + res\values-v21 + 1 + + + res\values-v21 + 1 + + + + + res\values + 1 + + + res\values + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\drawable-xxhdpi + 1 + + + res\drawable-xxhdpi + 1 + + + + + res\drawable-ldpi + 1 + + + res\drawable-ldpi + 1 + + + + + res\drawable-mdpi + 1 + + + res\drawable-mdpi + 1 + + + + + res\drawable-hdpi + 1 + + + res\drawable-hdpi + 1 + + + + + res\drawable-xhdpi + 1 + + + res\drawable-xhdpi + 1 + + + + + res\drawable-mdpi + 1 + + + res\drawable-mdpi + 1 + + + + + res\drawable-hdpi + 1 + + + res\drawable-hdpi + 1 + + + + + res\drawable-xhdpi + 1 + + + res\drawable-xhdpi + 1 + + + + + res\drawable-xxhdpi + 1 + + + res\drawable-xxhdpi + 1 + + + + + res\drawable-xxxhdpi + 1 + + + res\drawable-xxxhdpi + 1 + + + + + res\drawable-small + 1 + + + res\drawable-small + 1 + + + + + res\drawable-normal + 1 + + + res\drawable-normal + 1 + + + + + res\drawable-large + 1 + + + res\drawable-large + 1 + + + + + res\drawable-xlarge + 1 + + + res\drawable-xlarge + 1 + + + + + res\values + 1 + + + res\values + 1 + + + + + 1 + + + Contents\MacOS + 1 + + + 0 + + + + + Contents\MacOS + 1 + .framework + + + Contents\MacOS + 1 + .framework + + + 0 + + + + + 1 + .dylib + + + 1 + .dylib + + + 1 + .dylib + + + Contents\MacOS + 1 + .dylib + + + Contents\MacOS + 1 + .dylib + + + 0 + .dll;.bpl + + + + + 1 + .dylib + + + 1 + .dylib + + + 1 + .dylib + + + Contents\MacOS + 1 + .dylib + + + Contents\MacOS + 1 + .dylib + + + 0 + .bpl + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + Contents\Resources\StartUp\ + 0 + + + Contents\Resources\StartUp\ + 0 + + + 0 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + + + 1 + + + 1 + + + + + ..\ + 1 + + + ..\ + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + + + ..\ + 1 + + + ..\ + 1 + + + + + Contents + 1 + + + Contents + 1 + + + + + Contents\Resources + 1 + + + Contents\Resources + 1 + + + + + library\lib\armeabi-v7a + 1 + + + library\lib\arm64-v8a + 1 + + + 1 + + + 1 + + + 1 + + + 1 + + + Contents\MacOS + 1 + + + Contents\MacOS + 1 + + + 0 + + + + + library\lib\armeabi-v7a + 1 + + + + + 1 + + + 1 + + + + + Assets + 1 + + + Assets + 1 + + + + + Assets + 1 + + + Assets + 1 + + + + + + + + + + + + + + + True + False + + + 12 + + + + +
diff --git a/demos/Delphi_VCL/TabbedBrowser2/cef.inc b/demos/Delphi_VCL/TabbedBrowser2/cef.inc new file mode 100644 index 00000000..8334dc78 --- /dev/null +++ b/demos/Delphi_VCL/TabbedBrowser2/cef.inc @@ -0,0 +1,409 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + + // The complete list of compiler versions is here : + // http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Compiler_Versions + +{$DEFINE DELPHI_VERSION_UNKNOW} + +// Delphi 5 +{$IFDEF VER130} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} +{$ENDIF} + +// Delphi 6 +{$IFDEF VER140} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} +{$ENDIF} + +// Delphi 7 +{$IFDEF VER150} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} +{$ENDIF} + +// Delphi 8 +{$IFDEF VER160} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} +{$ENDIF} + +// Delphi 2005 +{$IFDEF VER170} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} +{$ENDIF} + +{$IFDEF VER180} + {$UNDEF DELPHI_VERSION_UNKNOW} + // Delphi 2007 + {$IFDEF VER185} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + // Delphi 2006 + {$ELSE} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$ENDIF} +{$ENDIF} + +// Delphi 2009 +{$IFDEF VER200} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} +{$ENDIF} + +//Delphi 2010 +{$IFDEF VER210} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} +{$ENDIF} + +// Delphi XE +{$IFDEF VER220} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} +{$ENDIF} + +// Delphi XE2 (First FireMonkey and 64bit compiler) +{$IFDEF VER230} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} +{$ENDIF} + +// Delphi XE3 +{$IFDEF VER240} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} +{$ENDIF} + +// Delphi XE4 +{$IFDEF VER250} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} + {$DEFINE DELPHI18_UP} +{$ENDIF} + +// Delphi XE5 +{$IFDEF VER260} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} + {$DEFINE DELPHI18_UP} + {$DEFINE DELPHI19_UP} +{$ENDIF} + +// Delphi XE6 +{$IFDEF VER270} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} + {$DEFINE DELPHI18_UP} + {$DEFINE DELPHI19_UP} + {$DEFINE DELPHI20_UP} +{$ENDIF} + +// Delphi XE7 +{$IFDEF VER280} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} + {$DEFINE DELPHI18_UP} + {$DEFINE DELPHI19_UP} + {$DEFINE DELPHI20_UP} + {$DEFINE DELPHI21_UP} +{$ENDIF} + +// Delphi XE8 +{$IFDEF VER290} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} + {$DEFINE DELPHI18_UP} + {$DEFINE DELPHI19_UP} + {$DEFINE DELPHI20_UP} + {$DEFINE DELPHI21_UP} + {$DEFINE DELPHI22_UP} +{$ENDIF VER290} + +// Rad Studio 10 - Delphi Seattle +{$IFDEF VER300} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} + {$DEFINE DELPHI18_UP} + {$DEFINE DELPHI19_UP} + {$DEFINE DELPHI20_UP} + {$DEFINE DELPHI21_UP} + {$DEFINE DELPHI22_UP} + {$DEFINE DELPHI23_UP} +{$ENDIF} + +// Rad Studio 10.1 - Delphi Berlin +{$IFDEF VER310} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} + {$DEFINE DELPHI18_UP} + {$DEFINE DELPHI19_UP} + {$DEFINE DELPHI20_UP} + {$DEFINE DELPHI21_UP} + {$DEFINE DELPHI22_UP} + {$DEFINE DELPHI23_UP} + {$DEFINE DELPHI24_UP} +{$ENDIF} + +// Rad Studio 10.2 - Delphi Tokyo +{$IFDEF VER320} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} + {$DEFINE DELPHI18_UP} + {$DEFINE DELPHI19_UP} + {$DEFINE DELPHI20_UP} + {$DEFINE DELPHI21_UP} + {$DEFINE DELPHI22_UP} + {$DEFINE DELPHI23_UP} + {$DEFINE DELPHI24_UP} + {$DEFINE DELPHI25_UP} +{$ENDIF} + +// Rad Studio 10.3 - Delphi Rio +{$IFDEF VER330} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} + {$DEFINE DELPHI18_UP} + {$DEFINE DELPHI19_UP} + {$DEFINE DELPHI20_UP} + {$DEFINE DELPHI21_UP} + {$DEFINE DELPHI22_UP} + {$DEFINE DELPHI23_UP} + {$DEFINE DELPHI24_UP} + {$DEFINE DELPHI25_UP} + {$DEFINE DELPHI26_UP} +{$ENDIF} + +{$IFDEF FPC} + {$DEFINE SUPPORTS_INLINE} +{$ELSE} + {$IFDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} + {$DEFINE DELPHI18_UP} + {$DEFINE DELPHI19_UP} + {$DEFINE DELPHI20_UP} + {$DEFINE DELPHI21_UP} + {$DEFINE DELPHI22_UP} + {$DEFINE DELPHI23_UP} + {$DEFINE DELPHI24_UP} + {$DEFINE DELPHI25_UP} + {$DEFINE DELPHI26_UP} + {$ENDIF} +{$ENDIF} + +{$IFDEF DELPHI9_UP} + {$DEFINE SUPPORTS_INLINE} +{$ENDIF} + diff --git a/demos/Delphi_VCL/TabbedBrowser2/uBrowserFrame.dfm b/demos/Delphi_VCL/TabbedBrowser2/uBrowserFrame.dfm new file mode 100644 index 00000000..60d93490 --- /dev/null +++ b/demos/Delphi_VCL/TabbedBrowser2/uBrowserFrame.dfm @@ -0,0 +1,231 @@ +object BrowserFrame: TBrowserFrame + Left = 0 + Top = 0 + Width = 932 + Height = 670 + TabOrder = 0 + object NavControlPnl: TPanel + Left = 0 + Top = 0 + Width = 932 + Height = 35 + Align = alTop + BevelOuter = bvNone + Enabled = False + TabOrder = 0 + object NavButtonPnl: TPanel + Left = 0 + Top = 0 + Width = 123 + Height = 35 + Align = alLeft + BevelOuter = bvNone + Padding.Left = 5 + Padding.Top = 5 + Padding.Right = 5 + Padding.Bottom = 5 + TabOrder = 0 + object BackBtn: TButton + Left = 5 + Top = 5 + Width = 25 + Height = 25 + Align = alLeft + Caption = '3' + Font.Charset = SYMBOL_CHARSET + Font.Color = clWindowText + Font.Height = -19 + Font.Name = 'Webdings' + Font.Style = [] + ParentFont = False + TabOrder = 0 + OnClick = BackBtnClick + end + object ForwardBtn: TButton + Left = 35 + Top = 5 + Width = 25 + Height = 25 + Caption = '4' + Font.Charset = SYMBOL_CHARSET + Font.Color = clWindowText + Font.Height = -19 + Font.Name = 'Webdings' + Font.Style = [] + ParentFont = False + TabOrder = 1 + OnClick = ForwardBtnClick + end + object ReloadBtn: TButton + Left = 64 + Top = 5 + Width = 25 + Height = 25 + Caption = 'q' + Font.Charset = SYMBOL_CHARSET + Font.Color = clWindowText + Font.Height = -19 + Font.Name = 'Webdings' + Font.Style = [] + ParentFont = False + TabOrder = 2 + OnClick = ReloadBtnClick + end + object StopBtn: TButton + Left = 93 + Top = 5 + Width = 25 + Height = 25 + Align = alRight + Caption = '=' + Font.Charset = SYMBOL_CHARSET + Font.Color = clWindowText + Font.Height = -19 + Font.Name = 'Webdings' + Font.Style = [] + ParentFont = False + TabOrder = 3 + OnClick = StopBtnClick + end + end + object URLEditPnl: TPanel + Left = 123 + Top = 0 + Width = 774 + Height = 35 + Align = alClient + BevelOuter = bvNone + Padding.Top = 7 + Padding.Bottom = 10 + TabOrder = 1 + object URLCbx: TComboBox + Left = 0 + Top = 7 + Width = 774 + Height = 21 + Align = alClient + ItemIndex = 0 + TabOrder = 0 + Text = 'https://www.google.com' + Items.Strings = ( + 'https://www.google.com' + + 'https://www.whatismybrowser.com/detect/what-http-headers-is-my-b' + + 'rowser-sending' + 'https://www.w3schools.com/js/tryit.asp?filename=tryjs_win_close' + 'https://www.w3schools.com/js/tryit.asp?filename=tryjs_alert' + 'https://www.w3schools.com/js/tryit.asp?filename=tryjs_loc_assign' + + 'https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_styl' + + 'e_backgroundcolor' + 'https://www.w3schools.com/html/html5_video.asp' + 'http://www.adobe.com/software/flash/about/' + 'http://isflashinstalled.com/' + 'https://helpx.adobe.com/flash-player.html' + 'https://www.ultrasounds.com/' + 'https://www.whatismybrowser.com/detect/is-flash-installed' + 'http://html5test.com/' + + 'https://webrtc.github.io/samples/src/content/devices/input-outpu' + + 't/' + 'https://test.webrtc.org/' + 'https://www.w3schools.com/' + 'http://webglsamples.org/' + 'https://get.webgl.org/' + 'https://www.briskbard.com' + 'https://www.youtube.com' + 'https://html5demos.com/drag/' + + 'https://developers.google.com/maps/documentation/javascript/exam' + + 'ples/streetview-embed?hl=fr' + + 'https://www.w3schools.com/Tags/tryit.asp?filename=tryhtml_iframe' + + '_name' + + 'http://www-db.deis.unibo.it/courses/TW/DOCS/w3schools/html/tryit' + + '.asp-filename=tryhtml5_html_manifest.html' + 'https://www.browserleaks.com/webrtc' + 'https://frames-per-second.appspot.com/' + 'chrome://version/' + 'chrome://net-internals/' + 'chrome://tracing/' + 'chrome://appcache-internals/' + 'chrome://blob-internals/' + 'chrome://view-http-cache/' + 'chrome://credits/' + 'chrome://histograms/' + 'chrome://media-internals/' + 'chrome://kill' + 'chrome://crash' + 'chrome://hang' + 'chrome://shorthang' + 'chrome://gpuclean' + 'chrome://gpucrash' + 'chrome://gpuhang' + 'chrome://extensions-support' + 'chrome://process-internals') + end + end + object ConfigPnl: TPanel + Left = 897 + Top = 0 + Width = 35 + Height = 35 + Align = alRight + BevelOuter = bvNone + Padding.Left = 5 + Padding.Top = 5 + Padding.Right = 5 + Padding.Bottom = 5 + TabOrder = 2 + object GoBtn: TButton + Left = 5 + Top = 5 + Width = 25 + Height = 25 + Align = alClient + Caption = #9658 + Font.Charset = ANSI_CHARSET + Font.Color = clWindowText + Font.Height = -17 + Font.Name = 'Arial' + Font.Style = [fsBold] + ParentFont = False + TabOrder = 0 + OnClick = GoBtnClick + end + end + end + object StatusBar1: TStatusBar + Left = 0 + Top = 651 + Width = 932 + Height = 19 + Panels = < + item + Width = 500 + end> + end + object CEFWindowParent1: TCEFWindowParent + Left = 0 + Top = 35 + Width = 932 + Height = 616 + Align = alClient + TabOrder = 2 + end + object Chromium1: TChromium + OnLoadError = Chromium1LoadError + OnLoadingStateChange = Chromium1LoadingStateChange + OnAddressChange = Chromium1AddressChange + OnTitleChange = Chromium1TitleChange + OnStatusMessage = Chromium1StatusMessage + OnBeforePopup = Chromium1BeforePopup + OnAfterCreated = Chromium1AfterCreated + OnBeforeClose = Chromium1BeforeClose + OnClose = Chromium1Close + OnOpenUrlFromTab = Chromium1OpenUrlFromTab + Left = 40 + Top = 72 + end +end diff --git a/demos/Delphi_VCL/TabbedBrowser2/uBrowserFrame.pas b/demos/Delphi_VCL/TabbedBrowser2/uBrowserFrame.pas new file mode 100644 index 00000000..b839f373 --- /dev/null +++ b/demos/Delphi_VCL/TabbedBrowser2/uBrowserFrame.pas @@ -0,0 +1,285 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2020 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * 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 DELPHI16_UP} + Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, + System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, + Vcl.ExtCtrls, Vcl.ComCtrls, Vcl.StdCtrls, + {$ELSE} + Windows, Messages, SysUtils, Variants, + Classes, Graphics, Controls, Forms, Dialogs, + ExtCtrls, ComCtrls, StdCtrls, + {$ENDIF} + uCEFWinControl, uCEFWindowParent, uCEFChromiumCore, uCEFChromium, + uCEFInterfaces, uCEFTypes, uCEFConstants; + +type + TBrowserTitleEvent = procedure(Sender: TObject; const aTitle : string) of object; + + TBrowserFrame = class(TFrame) + NavControlPnl: TPanel; + NavButtonPnl: TPanel; + BackBtn: TButton; + ForwardBtn: TButton; + ReloadBtn: TButton; + StopBtn: TButton; + URLEditPnl: TPanel; + URLCbx: TComboBox; + ConfigPnl: TPanel; + GoBtn: TButton; + StatusBar1: TStatusBar; + Chromium1: TChromium; + CEFWindowParent1: TCEFWindowParent; + + procedure Chromium1AfterCreated(Sender: TObject; const browser: ICefBrowser); + procedure Chromium1AddressChange(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const url: ustring); + procedure Chromium1BeforeClose(Sender: TObject; const browser: ICefBrowser); + procedure Chromium1Close(Sender: TObject; const browser: ICefBrowser; var aAction: TCefCloseBrowserAction); + procedure Chromium1LoadError(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; errorCode: Integer; const errorText, failedUrl: ustring); + procedure Chromium1LoadingStateChange(Sender: TObject; const browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean); + procedure Chromium1StatusMessage(Sender: TObject; const browser: ICefBrowser; const value: ustring); + procedure Chromium1TitleChange(Sender: TObject; const browser: ICefBrowser; const title: ustring); + procedure Chromium1BeforePopup(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 Chromium1OpenUrlFromTab(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; out Result: Boolean); + + procedure BackBtnClick(Sender: TObject); + procedure ForwardBtnClick(Sender: TObject); + procedure ReloadBtnClick(Sender: TObject); + procedure StopBtnClick(Sender: TObject); + procedure GoBtnClick(Sender: TObject); + + protected + FClosing : boolean; // Indicates that this frame is destroying the browser + FHomepage : string; + FOnBrowserDestroyed : TNotifyEvent; + FOnBrowserTitleChange : TBrowserTitleEvent; + + procedure BrowserCreatedMsg(var aMessage : TMessage); message CEF_AFTERCREATED; + procedure BrowserDestroyMsg(var aMessage : TMessage); message CEF_DESTROY; + + public + constructor Create(AOwner : TComponent); override; + procedure NotifyMoveOrResizeStarted; + procedure CreateBrowser; + procedure CloseBrowser; + + 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; + end; + +implementation + +{$R *.dfm} + +constructor TBrowserFrame.Create(AOwner : TComponent); +begin + inherited Create(AOwner); + + FClosing := False; + FHomepage := ''; + FOnBrowserDestroyed := nil; + FOnBrowserTitleChange := nil; +end; + +procedure TBrowserFrame.NotifyMoveOrResizeStarted; +begin + Chromium1.NotifyMoveOrResizeStarted; +end; + +procedure TBrowserFrame.ReloadBtnClick(Sender: TObject); +begin + Chromium1.Reload; +end; + +procedure TBrowserFrame.StopBtnClick(Sender: TObject); +begin + Chromium1.StopLoad; +end; + +procedure TBrowserFrame.CreateBrowser; +begin + Chromium1.DefaultURL := FHomepage; + Chromium1.CreateBrowser(CEFWindowParent1); +end; + +procedure TBrowserFrame.CloseBrowser; +begin + if not(FClosing) then + begin + FClosing := True; + NavControlPnl.Enabled := False; + Chromium1.CloseBrowser(True); + end; +end; + +procedure TBrowserFrame.ForwardBtnClick(Sender: TObject); +begin + Chromium1.GoForward; +end; + +procedure TBrowserFrame.GoBtnClick(Sender: TObject); +begin + Chromium1.LoadURL(URLCbx.Text); +end; + +procedure TBrowserFrame.Chromium1AfterCreated(Sender: TObject; + const browser: ICefBrowser); +begin + PostMessage(Handle, CEF_AFTERCREATED, 0, 0); +end; + +procedure TBrowserFrame.BackBtnClick(Sender: TObject); +begin + Chromium1.GoBack; +end; + +procedure TBrowserFrame.Chromium1AddressChange(Sender: TObject; + const browser: ICefBrowser; const frame: ICefFrame; const url: ustring); +begin + if (URLCbx.Items.IndexOf(url) < 0) then URLCbx.Items.Add(url); + + URLCbx.Text := url; +end; + +procedure TBrowserFrame.Chromium1BeforeClose(Sender: TObject; + const browser: ICefBrowser); +begin + if assigned(FOnBrowserDestroyed) then FOnBrowserDestroyed(self); +end; + +procedure TBrowserFrame.Chromium1BeforePopup(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.Chromium1Close(Sender: TObject; + const browser: ICefBrowser; var aAction: TCefCloseBrowserAction); +begin + PostMessage(Handle, CEF_DESTROY, 0, 0); + aAction := cbaDelay; +end; + +procedure TBrowserFrame.Chromium1LoadError(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 := '' + + '

Failed to load URL ' + failedUrl + + ' with error ' + errorText + + ' (' + inttostr(errorCode) + ').

'; + + Chromium1.LoadString(TempString, frame); +end; + +procedure TBrowserFrame.Chromium1LoadingStateChange(Sender: TObject; + const browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean); +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; + +procedure TBrowserFrame.Chromium1OpenUrlFromTab(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.Chromium1StatusMessage(Sender: TObject; + const browser: ICefBrowser; const value: ustring); +begin + StatusBar1.Panels[0].Text := value; +end; + +procedure TBrowserFrame.Chromium1TitleChange(Sender: TObject; + const browser: ICefBrowser; const title: ustring); +begin + if not(assigned(FOnBrowserTitleChange)) then exit; + + if (length(title) > 0) then + FOnBrowserTitleChange(self, title) + else + FOnBrowserTitleChange(self, Chromium1.DocumentURL); +end; + +procedure TBrowserFrame.BrowserCreatedMsg(var aMessage : TMessage); +begin + CEFWindowParent1.UpdateSize; + NavControlPnl.Enabled := True; +end; + +procedure TBrowserFrame.BrowserDestroyMsg(var aMessage : TMessage); +begin + CEFWindowParent1.Free; +end; + +end. + + diff --git a/demos/Delphi_VCL/TabbedBrowser2/uBrowserTab.pas b/demos/Delphi_VCL/TabbedBrowser2/uBrowserTab.pas new file mode 100644 index 00000000..46eeb536 --- /dev/null +++ b/demos/Delphi_VCL/TabbedBrowser2/uBrowserTab.pas @@ -0,0 +1,152 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2020 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * 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 + {$IFDEF DELPHI16_UP} + Winapi.Windows, System.Classes, Winapi.Messages, Vcl.ComCtrls, Vcl.Controls, + Vcl.Forms, + {$ELSE} + Windows, Classes, Messages, ComCtrls, Controls, + Forms, + {$ENDIF} + uBrowserFrame; + +type + TBrowserTab = class(TTabSheet) + protected + FBrowserFrame : TBrowserFrame; + FTabID : cardinal; + + function GetParentForm : TCustomForm; + + function PostFormMessage(aMsg : cardinal; wParam : cardinal = 0; lParam : integer = 0) : boolean; + + procedure BrowserFrame_OnBrowserDestroyed(Sender: TObject); + procedure BrowserFrame_OnBrowserTitleChange(Sender: TObject; const aTitle : string); + + property ParentForm : TCustomForm read GetParentForm; + + public + constructor Create(AOwner: TComponent; aTabID : cardinal; const aCaption : string); reintroduce; + procedure NotifyMoveOrResizeStarted; + procedure CreateBrowser(const aHomepage : string); + procedure CloseBrowser; + + property TabID : cardinal read FTabID; + end; + +implementation + +uses + uMainForm; + +constructor TBrowserTab.Create(AOwner: TComponent; aTabID : cardinal; const aCaption : string); +begin + inherited Create(AOwner); + + FTabID := aTabID; + Caption := aCaption; + FBrowserFrame := nil; +end; + +function TBrowserTab.GetParentForm : TCustomForm; +var + TempParent : TWinControl; +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.HandleAllocated and + PostMessage(TempForm.Handle, aMsg, wParam, lParam); +end; + +procedure TBrowserTab.NotifyMoveOrResizeStarted; +begin + FBrowserFrame.NotifyMoveOrResizeStarted; +end; + +procedure TBrowserTab.CreateBrowser(const aHomepage : string); +begin + FBrowserFrame := TBrowserFrame.Create(self); + FBrowserFrame.Parent := self; + FBrowserFrame.Align := alClient; + FBrowserFrame.Visible := True; + FBrowserFrame.Homepage := aHomepage; + FBrowserFrame.OnBrowserDestroyed := BrowserFrame_OnBrowserDestroyed; + FBrowserFrame.OnBrowserTitleChange := BrowserFrame_OnBrowserTitleChange; + + FBrowserFrame.CreateBrowser; +end; + +procedure TBrowserTab.CloseBrowser; +begin + if (FBrowserFrame <> nil) then FBrowserFrame.CloseBrowser; +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 + Caption := aTitle; +end; + +end. diff --git a/demos/Delphi_VCL/TabbedBrowser2/uMainForm.dfm b/demos/Delphi_VCL/TabbedBrowser2/uMainForm.dfm new file mode 100644 index 00000000..65371f7e --- /dev/null +++ b/demos/Delphi_VCL/TabbedBrowser2/uMainForm.dfm @@ -0,0 +1,76 @@ +object MainForm: TMainForm + Left = 0 + Top = 0 + Caption = 'Initializing. Please, wait...' + ClientHeight = 703 + ClientWidth = 991 + Color = clBtnFace + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + OldCreateOrder = False + Position = poScreenCenter + OnCloseQuery = FormCloseQuery + OnCreate = FormCreate + OnShow = FormShow + PixelsPerInch = 96 + TextHeight = 13 + object BrowserPageCtrl: TPageControl + Left = 32 + Top = 0 + Width = 959 + Height = 703 + Align = alClient + TabOrder = 0 + end + object ButtonPnl: TPanel + Left = 0 + Top = 0 + Width = 32 + Height = 703 + Align = alLeft + BevelOuter = bvNone + Enabled = False + Padding.Left = 3 + Padding.Top = 3 + Padding.Right = 3 + Padding.Bottom = 3 + TabOrder = 1 + DesignSize = ( + 32 + 703) + object AddTabBtn: TSpeedButton + Left = 3 + Top = 3 + Width = 26 + Height = 26 + Align = alTop + Caption = '+' + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -24 + Font.Name = 'Arial Black' + Font.Style = [] + ParentFont = False + OnClick = AddTabBtnClick + ExplicitWidth = 27 + end + object RemoveTabBtn: TSpeedButton + Left = 3 + Top = 32 + Width = 26 + Height = 26 + Anchors = [akLeft, akTop, akRight] + Caption = #8722 + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -24 + Font.Name = 'Arial Black' + Font.Style = [] + ParentFont = False + OnClick = RemoveTabBtnClick + end + end +end diff --git a/demos/Delphi_VCL/TabbedBrowser2/uMainForm.pas b/demos/Delphi_VCL/TabbedBrowser2/uMainForm.pas new file mode 100644 index 00000000..c3eb5b16 --- /dev/null +++ b/demos/Delphi_VCL/TabbedBrowser2/uMainForm.pas @@ -0,0 +1,319 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2020 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest + * 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 DELPHI16_UP} + Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, + Vcl.Controls, Vcl.Forms, Vcl.Dialogs, + Vcl.ComCtrls, Vcl.ToolWin, Vcl.Buttons, Vcl.ExtCtrls, + {$ELSE} + Windows, Messages, SysUtils, Variants, Classes, Graphics, + Controls, Forms, Dialogs, + ComCtrls, ToolWin, Buttons, ExtCtrls, + {$ENDIF} + uCEFApplication, uCEFTypes, uCEFConstants; + +const + CEF_INITIALIZED = WM_APP + $100; + CEF_DESTROYTAB = WM_APP + $101; + + HOMEPAGE_URL = 'https://www.google.com'; + DEFAULT_TAB_CAPTION = 'New tab'; + +type + TMainForm = class(TForm) + BrowserPageCtrl: TPageControl; + ButtonPnl: TPanel; + AddTabBtn: TSpeedButton; + RemoveTabBtn: TSpeedButton; + + procedure AddTabBtnClick(Sender: TObject); + procedure RemoveTabBtnClick(Sender: TObject); + + procedure FormShow(Sender: TObject); + procedure FormCreate(Sender: TObject); + procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); + + 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 + + function GetNextTabID : cardinal; + + procedure EnableButtonPnl; + function CloseAllTabs : boolean; + procedure CloseTab(aIndex : integer); + + procedure CEFInitializedMsg(var aMessage : TMessage); message CEF_INITIALIZED; + procedure DestroyTabMsg(var aMessage : TMessage); message CEF_DESTROYTAB; + procedure WMMove(var aMessage : TWMMove); message WM_MOVE; + procedure WMMoving(var aMessage : TMessage); message WM_MOVING; + procedure WMEnterMenuLoop(var aMessage: TMessage); message WM_ENTERMENULOOP; + procedure WMExitMenuLoop(var aMessage: TMessage); message WM_EXITMENULOOP; + + property NextTabID : cardinal read GetNextTabID; + end; + +var + MainForm: TMainForm; + +procedure CreateGlobalCEFApp; + +implementation + +{$R *.dfm} + +uses + uBrowserTab; + +// This demo shows how to use a TPageControl with TFrames that include +// CEF4Delphi browsers. + +// Instead of a regular TTabSheet we use a custom TBrowserTab class that +// inherits from TTabSheet 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 free it. + +// TBrowserFrame has all the usual code to close CEF4Delphi browsers following +// a similar destruction sequence than the MiniBrowser demo : +// +// 1. TBrowserTab.CloseBrowser calls TChromium.CloseBrowser which triggers the +// TChromium.OnClose event. +// 2. TChromium.OnClose sends a CEF_DESTROY 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 TPageControl has no tabs then we can set FCanClose to TRUE and send a +// WM_CLOSE to the main form to close the application. + +procedure GlobalCEFApp_OnContextInitialized; +begin + if (MainForm <> nil) and MainForm.HandleAllocated then + PostMessage(MainForm.Handle, CEF_INITIALIZED, 0, 0); +end; + +procedure CreateGlobalCEFApp; +begin + GlobalCEFApp := TCefApplication.Create; + GlobalCEFApp.cache := 'cache'; + GlobalCEFApp.OnContextInitialized := GlobalCEFApp_OnContextInitialized; +end; + +procedure TMainForm.EnableButtonPnl; +begin + if not(ButtonPnl.Enabled) then + begin + ButtonPnl.Enabled := True; + Caption := 'Tabbed Browser 2'; + cursor := crDefault; + if (BrowserPageCtrl.PageCount = 0) then AddTabBtn.Click; + end; +end; + +function TMainForm.GetNextTabID : cardinal; +begin + inc(FLastTabID); + Result := FLastTabID; +end; + +procedure TMainForm.AddTabBtnClick(Sender: TObject); +var + TempNewTab : TBrowserTab; +begin + TempNewTab := TBrowserTab.Create(self, NextTabID, DEFAULT_TAB_CAPTION); + TempNewTab.PageControl := BrowserPageCtrl; + + BrowserPageCtrl.ActivePageIndex := pred(BrowserPageCtrl.PageCount); + + TempNewTab.CreateBrowser(HOMEPAGE_URL); +end; + +procedure TMainForm.CEFInitializedMsg(var aMessage : TMessage); +begin + EnableButtonPnl; +end; + +procedure TMainForm.DestroyTabMsg(var aMessage : TMessage); +var + i : integer; + TempTab : TBrowserTab; +begin + i := 0; + while (i < BrowserPageCtrl.PageCount) do + begin + TempTab := TBrowserTab(BrowserPageCtrl.Pages[i]); + + if (TempTab.TabID = aMessage.wParam) then + begin + TempTab.Free; + break; + end + else + inc(i); + end; + + if FClosing and (BrowserPageCtrl.PageCount = 0) then + begin + FCanClose := True; + PostMessage(Handle, WM_CLOSE, 0, 0); + end; +end; + +procedure TMainForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean); +begin + CanClose := FCanClose; + + if not(FClosing) then + begin + FClosing := True; + ButtonPnl.Enabled := False; + + if not(CloseAllTabs) then + begin + FCanClose := True; + PostMessage(Handle, WM_CLOSE, 0, 0); + end; + end; +end; + +procedure TMainForm.FormCreate(Sender: TObject); +begin + FCanClose := False; + FClosing := False; + FLastTabID := 0; +end; + +procedure TMainForm.FormShow(Sender: TObject); +begin + if (GlobalCEFApp <> nil) and GlobalCEFApp.GlobalContextInitialized then + EnableButtonPnl; +end; + +procedure TMainForm.RemoveTabBtnClick(Sender: TObject); +begin + CloseTab(BrowserPageCtrl.ActivePageIndex); +end; + +function TMainForm.CloseAllTabs : boolean; +var + i : integer; +begin + Result := False; + i := pred(BrowserPageCtrl.PageCount); + + while (i >= 0) do + begin + TBrowserTab(BrowserPageCtrl.Pages[i]).CloseBrowser; + Result := True; + dec(i); + end; +end; + +procedure TMainForm.CloseTab(aIndex : integer); +begin + if (aIndex >= 0) and (aIndex < BrowserPageCtrl.PageCount) then + TBrowserTab(BrowserPageCtrl.Pages[aIndex]).CloseBrowser; +end; + +procedure TMainForm.WMMove(var aMessage : TWMMove); +var + i : integer; +begin + inherited; + + i := 0; + while (i < BrowserPageCtrl.PageCount) do + begin + TBrowserTab(BrowserPageCtrl.Pages[i]).NotifyMoveOrResizeStarted; + inc(i); + end; +end; + +procedure TMainForm.WMMoving(var aMessage : TMessage); +var + i : integer; +begin + inherited; + + i := 0; + while (i < BrowserPageCtrl.PageCount) do + begin + TBrowserTab(BrowserPageCtrl.Pages[i]).NotifyMoveOrResizeStarted; + inc(i); + end; +end; + +procedure TMainForm.WMEnterMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then + GlobalCEFApp.OsmodalLoop := True; +end; + +procedure TMainForm.WMExitMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then + GlobalCEFApp.OsmodalLoop := False; +end; + +end. diff --git a/demos/Lazarus/TabbedBrowser2/00-Delete.bat b/demos/Lazarus/TabbedBrowser2/00-Delete.bat new file mode 100644 index 00000000..0b5ba5c8 --- /dev/null +++ b/demos/Lazarus/TabbedBrowser2/00-Delete.bat @@ -0,0 +1,2 @@ +rmdir /S /Q lib +rmdir /S /Q backup diff --git a/demos/Lazarus/TabbedBrowser2/TabbedBrowser2.dproj b/demos/Lazarus/TabbedBrowser2/TabbedBrowser2.dproj new file mode 100644 index 00000000..c6a0dab1 --- /dev/null +++ b/demos/Lazarus/TabbedBrowser2/TabbedBrowser2.dproj @@ -0,0 +1,983 @@ + + + {2A491C1D-D0F3-4D4B-9606-F7FC09C7713E} + 18.8 + VCL + TabbedBrowser2.dpr + True + Debug + Win32 + 1 + Application + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_1 + true + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + .\$(Platform)\$(Config) + ..\..\..\bin + false + false + false + false + false + System;Xml;Data;Datasnap;Web;Soap;Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;$(DCC_Namespace) + $(BDS)\bin\delphi_PROJECTICON.ico + $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png + $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png + TabbedBrowser2 + 3082 + CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= + + + DBXSqliteDriver;bindcompdbx;fmxase;DBXDb2Driver;DBXInterBaseDriver;vcl;DBXSybaseASEDriver;vclactnband;RESTComponents;vclFireDAC;IndyProtocols250;FireDACDb2Driver;IndyCore250;DataSnapFireDAC;svnui;tethering;dsnapcon;FireDACADSDriver;FireDACMSAccDriver;fmxFireDAC;DBXMSSQLDriver;vclimg;FireDACInfxDriver;DatasnapConnectorsFreePascal;FireDAC;FireDACMSSQLDriver;vcltouch;Componentes_UI;vcldb;bindcompfmx;svn;Detours;FireDACSqliteDriver;FireDACPgDriver;DBXOracleDriver;inetdb;FireDACASADriver;DBXOdbcDriver;FireDACTDataDriver;SVGPackage;soaprtl;DbxCommonDriver;FireDACIBDriver;fmx;DataSnapServer;xmlrtl;soapmidas;DataSnapNativeClient;fmxobj;fmxdae;vclwinx;rtl;FireDACDSDriver;DbxClientDriver;DBXSybaseASADriver;CustomIPTransport;vcldsnap;dbexpress;FireDACDBXDriver;vclx;bindcomp;appanalytics;dsnap;DataSnapCommon;DBXInformixDriver;FireDACCommon;bindcompvcl;RESTBackendComponents;DataSnapConnectors;VCLRESTComponents;soapserver;dbxcds;VclSmp;adortl;FireDACODBCDriver;DataSnapIndy10ServerTransport;vclie;CEF4Delphi_FMX;bindengine;DBXMySQLDriver;FireDACOracleDriver;dsnapxml;FireDACMySQLDriver;dbrtl;inetdbxpress;DBXFirebirdDriver;DataSnapProviderClient;FireDACMongoDBDriver;FireDACCommonODBC;FireDACCommonDriver;CloudService;DataSnapClient;VisualStyles;IndySystem250;inet;DataSnapServerMidas;$(DCC_UsePackage) + Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) + Debug + true + CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= + 1033 + $(BDS)\bin\default_app.manifest + + + DBXSqliteDriver;bindcompdbx;fmxase;DBXDb2Driver;DBXInterBaseDriver;vcl;DBXSybaseASEDriver;vclactnband;RESTComponents;vclFireDAC;IndyProtocols250;FireDACDb2Driver;IndyCore250;DataSnapFireDAC;tethering;dsnapcon;FireDACADSDriver;FireDACMSAccDriver;fmxFireDAC;DBXMSSQLDriver;vclimg;FireDACInfxDriver;DatasnapConnectorsFreePascal;FireDAC;FireDACMSSQLDriver;vcltouch;vcldb;bindcompfmx;FireDACSqliteDriver;FireDACPgDriver;DBXOracleDriver;inetdb;FireDACASADriver;DBXOdbcDriver;FireDACTDataDriver;soaprtl;DbxCommonDriver;FireDACIBDriver;fmx;DataSnapServer;xmlrtl;soapmidas;DataSnapNativeClient;fmxobj;fmxdae;vclwinx;rtl;FireDACDSDriver;DbxClientDriver;DBXSybaseASADriver;CustomIPTransport;vcldsnap;dbexpress;FireDACDBXDriver;vclx;bindcomp;appanalytics;dsnap;DataSnapCommon;DBXInformixDriver;FireDACCommon;bindcompvcl;RESTBackendComponents;DataSnapConnectors;VCLRESTComponents;soapserver;dbxcds;VclSmp;adortl;FireDACODBCDriver;DataSnapIndy10ServerTransport;vclie;CEF4Delphi_FMX;bindengine;DBXMySQLDriver;FireDACOracleDriver;dsnapxml;FireDACMySQLDriver;dbrtl;inetdbxpress;DBXFirebirdDriver;DataSnapProviderClient;FireDACMongoDBDriver;FireDACCommonODBC;FireDACCommonDriver;CloudService;DataSnapClient;IndySystem250;inet;DataSnapServerMidas;$(DCC_UsePackage) + + + DEBUG;$(DCC_Define) + true + false + true + true + true + + + false + true + PerMonitorV2 + true + 1033 + + + false + RELEASE;$(DCC_Define) + 0 + 0 + + + true + PerMonitorV2 + + + + MainSource + + +
MainForm
+
+ +
BrowserFrame
+ TFrame +
+ + + Cfg_2 + Base + + + Base + + + Cfg_1 + Base + +
+ + Delphi.Personality.12 + Application + + + + TabbedBrowser2.dpr + + + IP Abstraction Indy Implementation Design Time + Microsoft Office 2000 Sample Automation Server Wrapper Components + Microsoft Office XP Sample Automation Server Wrapper Components + + + + + + TabbedBrowser2.exe + true + + + + + 1 + + + Contents\MacOS + 1 + + + 0 + + + + + classes + 1 + + + classes + 1 + + + + + res\xml + 1 + + + res\xml + 1 + + + + + library\lib\armeabi-v7a + 1 + + + + + library\lib\armeabi + 1 + + + library\lib\armeabi + 1 + + + + + library\lib\armeabi-v7a + 1 + + + + + library\lib\mips + 1 + + + library\lib\mips + 1 + + + + + library\lib\armeabi-v7a + 1 + + + library\lib\arm64-v8a + 1 + + + + + library\lib\armeabi-v7a + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\values + 1 + + + res\values + 1 + + + + + res\values-v21 + 1 + + + res\values-v21 + 1 + + + + + res\values + 1 + + + res\values + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\drawable-xxhdpi + 1 + + + res\drawable-xxhdpi + 1 + + + + + res\drawable-ldpi + 1 + + + res\drawable-ldpi + 1 + + + + + res\drawable-mdpi + 1 + + + res\drawable-mdpi + 1 + + + + + res\drawable-hdpi + 1 + + + res\drawable-hdpi + 1 + + + + + res\drawable-xhdpi + 1 + + + res\drawable-xhdpi + 1 + + + + + res\drawable-mdpi + 1 + + + res\drawable-mdpi + 1 + + + + + res\drawable-hdpi + 1 + + + res\drawable-hdpi + 1 + + + + + res\drawable-xhdpi + 1 + + + res\drawable-xhdpi + 1 + + + + + res\drawable-xxhdpi + 1 + + + res\drawable-xxhdpi + 1 + + + + + res\drawable-xxxhdpi + 1 + + + res\drawable-xxxhdpi + 1 + + + + + res\drawable-small + 1 + + + res\drawable-small + 1 + + + + + res\drawable-normal + 1 + + + res\drawable-normal + 1 + + + + + res\drawable-large + 1 + + + res\drawable-large + 1 + + + + + res\drawable-xlarge + 1 + + + res\drawable-xlarge + 1 + + + + + res\values + 1 + + + res\values + 1 + + + + + 1 + + + Contents\MacOS + 1 + + + 0 + + + + + Contents\MacOS + 1 + .framework + + + Contents\MacOS + 1 + .framework + + + 0 + + + + + 1 + .dylib + + + 1 + .dylib + + + 1 + .dylib + + + Contents\MacOS + 1 + .dylib + + + Contents\MacOS + 1 + .dylib + + + 0 + .dll;.bpl + + + + + 1 + .dylib + + + 1 + .dylib + + + 1 + .dylib + + + Contents\MacOS + 1 + .dylib + + + Contents\MacOS + 1 + .dylib + + + 0 + .bpl + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + Contents\Resources\StartUp\ + 0 + + + Contents\Resources\StartUp\ + 0 + + + 0 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + + + 1 + + + 1 + + + + + ..\ + 1 + + + ..\ + 1 + + + + + 1 + + + 1 + + + 1 + + + + + 1 + + + 1 + + + 1 + + + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + + + ..\ + 1 + + + ..\ + 1 + + + + + Contents + 1 + + + Contents + 1 + + + + + Contents\Resources + 1 + + + Contents\Resources + 1 + + + + + library\lib\armeabi-v7a + 1 + + + library\lib\arm64-v8a + 1 + + + 1 + + + 1 + + + 1 + + + 1 + + + Contents\MacOS + 1 + + + Contents\MacOS + 1 + + + 0 + + + + + library\lib\armeabi-v7a + 1 + + + + + 1 + + + 1 + + + + + Assets + 1 + + + Assets + 1 + + + + + Assets + 1 + + + Assets + 1 + + + + + + + + + + + + + + + True + False + + + 12 + + + + +
diff --git a/demos/Lazarus/TabbedBrowser2/TabbedBrowser2.lpi b/demos/Lazarus/TabbedBrowser2/TabbedBrowser2.lpi new file mode 100644 index 00000000..e4f2fe9d --- /dev/null +++ b/demos/Lazarus/TabbedBrowser2/TabbedBrowser2.lpi @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + <UseAppBundle Value="False"/> + <ResourceType Value="res"/> + </General> + <BuildModes Count="1"> + <Item1 Name="Default" Default="True"/> + </BuildModes> + <PublishOptions> + <Version Value="2"/> + <UseFileFilters Value="True"/> + </PublishOptions> + <RunParams> + <FormatVersion Value="2"/> + <Modes Count="0"/> + </RunParams> + <RequiredPackages Count="2"> + <Item1> + <PackageName Value="CEF4Delphi_Lazarus"/> + </Item1> + <Item2> + <PackageName Value="LCL"/> + </Item2> + </RequiredPackages> + <Units Count="4"> + <Unit0> + <Filename Value="TabbedBrowser2.lpr"/> + <IsPartOfProject Value="True"/> + </Unit0> + <Unit1> + <Filename Value="uMainForm.pas"/> + <IsPartOfProject Value="True"/> + <ComponentName Value="MainForm"/> + <HasResources Value="True"/> + <ResourceBaseClass Value="Form"/> + </Unit1> + <Unit2> + <Filename Value="uBrowserFrame.pas"/> + <IsPartOfProject Value="True"/> + <ComponentName Value="BrowserFrame"/> + <HasResources Value="True"/> + <ResourceBaseClass Value="Frame"/> + </Unit2> + <Unit3> + <Filename Value="uBrowserTab.pas"/> + <IsPartOfProject Value="True"/> + </Unit3> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="11"/> + <PathDelim Value="\"/> + <Target> + <Filename Value="..\..\..\bin\TabbedBrowser2"/> + </Target> + <SearchPaths> + <IncludeFiles Value="$(ProjOutDir)"/> + <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> + </SearchPaths> + <Parsing> + <SyntaxOptions> + <SyntaxMode Value="Delphi"/> + </SyntaxOptions> + </Parsing> + <Linking> + <Options> + <Win32> + <GraphicApplication Value="True"/> + </Win32> + </Options> + </Linking> + <Other> + <CustomOptions Value="-dBorland -dVer150 -dDelphi7 -dCompiler6_Up -dPUREPASCAL"/> + </Other> + </CompilerOptions> + <Debugging> + <Exceptions Count="3"> + <Item1> + <Name Value="EAbort"/> + </Item1> + <Item2> + <Name Value="ECodetoolError"/> + </Item2> + <Item3> + <Name Value="EFOpenError"/> + </Item3> + </Exceptions> + </Debugging> +</CONFIG> diff --git a/demos/Lazarus/TabbedBrowser2/TabbedBrowser2.lpr b/demos/Lazarus/TabbedBrowser2/TabbedBrowser2.lpr new file mode 100644 index 00000000..94758ad2 --- /dev/null +++ b/demos/Lazarus/TabbedBrowser2/TabbedBrowser2.lpr @@ -0,0 +1,69 @@ +// ************************************************************************ +// ***************************** 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 TabbedBrowser2; + +{$MODE Delphi} + +{$I cef.inc} + +uses + Forms, + LCLIntf, LCLType, LMessages, Interfaces, + uCEFApplication, + uMainForm in 'uMainForm.pas' {MainForm}, + uBrowserFrame in 'uBrowserFrame.pas' {BrowserFrame: TFrame}, + uBrowserTab in 'uBrowserTab.pas'; + +{.$R *.res} + +// CEF needs to set the LARGEADDRESSAWARE flag which allows 32-bit processes to use up to 3GB of RAM. +// If you don't add this flag the rederer process will crash when you try to load large images. +{$SetPEFlags $20} + +begin + CreateGlobalCEFApp; + + if GlobalCEFApp.StartMainProcess then + begin + Application.Initialize; + Application.CreateForm(TMainForm, MainForm); + Application.Run; + end; + + DestroyGlobalCEFApp; +end. diff --git a/demos/Lazarus/TabbedBrowser2/TabbedBrowser2.lps b/demos/Lazarus/TabbedBrowser2/TabbedBrowser2.lps new file mode 100644 index 00000000..6c5f1668 --- /dev/null +++ b/demos/Lazarus/TabbedBrowser2/TabbedBrowser2.lps @@ -0,0 +1,68 @@ +<?xml version="1.0" encoding="UTF-8"?> +<CONFIG> + <ProjectSession> + <PathDelim Value="\"/> + <Version Value="11"/> + <BuildModes Active="Default"/> + <Units Count="4"> + <Unit0> + <Filename Value="TabbedBrowser2.lpr"/> + <IsPartOfProject Value="True"/> + <TopLine Value="40"/> + <CursorPos X="50" Y="62"/> + <UsageCount Value="20"/> + <Loaded Value="True"/> + <DefaultSyntaxHighlighter Value="Delphi"/> + </Unit0> + <Unit1> + <Filename Value="uMainForm.pas"/> + <IsPartOfProject Value="True"/> + <ComponentName Value="MainForm"/> + <HasResources Value="True"/> + <ResourceBaseClass Value="Form"/> + <EditorIndex Value="1"/> + <TopLine Value="120"/> + <CursorPos X="67" Y="137"/> + <UsageCount Value="20"/> + <Loaded Value="True"/> + <LoadedDesigner Value="True"/> + <DefaultSyntaxHighlighter Value="Delphi"/> + </Unit1> + <Unit2> + <Filename Value="uBrowserFrame.pas"/> + <IsPartOfProject Value="True"/> + <ComponentName Value="BrowserFrame"/> + <HasResources Value="True"/> + <ResourceBaseClass Value="Frame"/> + <EditorIndex Value="3"/> + <TopLine Value="107"/> + <CursorPos X="57" Y="122"/> + <UsageCount Value="20"/> + <Loaded Value="True"/> + <LoadedDesigner Value="True"/> + <DefaultSyntaxHighlighter Value="Delphi"/> + </Unit2> + <Unit3> + <Filename Value="uBrowserTab.pas"/> + <IsPartOfProject Value="True"/> + <IsVisibleTab Value="True"/> + <EditorIndex Value="2"/> + <TopLine Value="118"/> + <CursorPos X="53" Y="140"/> + <UsageCount Value="20"/> + <Loaded Value="True"/> + <DefaultSyntaxHighlighter Value="Delphi"/> + </Unit3> + </Units> + <JumpHistory Count="1"> + <Position1> + <Filename Value="uBrowserFrame.pas"/> + <Caret Line="8" Column="83"/> + </Position1> + </JumpHistory> + <RunParams> + <FormatVersion Value="2"/> + <Modes Count="0" ActiveMode=""/> + </RunParams> + </ProjectSession> +</CONFIG> diff --git a/demos/Lazarus/TabbedBrowser2/cef.inc b/demos/Lazarus/TabbedBrowser2/cef.inc new file mode 100644 index 00000000..8334dc78 --- /dev/null +++ b/demos/Lazarus/TabbedBrowser2/cef.inc @@ -0,0 +1,409 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2017 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest <hgourvest@gmail.com> + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + + // The complete list of compiler versions is here : + // http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Compiler_Versions + +{$DEFINE DELPHI_VERSION_UNKNOW} + +// Delphi 5 +{$IFDEF VER130} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} +{$ENDIF} + +// Delphi 6 +{$IFDEF VER140} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} +{$ENDIF} + +// Delphi 7 +{$IFDEF VER150} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} +{$ENDIF} + +// Delphi 8 +{$IFDEF VER160} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} +{$ENDIF} + +// Delphi 2005 +{$IFDEF VER170} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} +{$ENDIF} + +{$IFDEF VER180} + {$UNDEF DELPHI_VERSION_UNKNOW} + // Delphi 2007 + {$IFDEF VER185} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + // Delphi 2006 + {$ELSE} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$ENDIF} +{$ENDIF} + +// Delphi 2009 +{$IFDEF VER200} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} +{$ENDIF} + +//Delphi 2010 +{$IFDEF VER210} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} +{$ENDIF} + +// Delphi XE +{$IFDEF VER220} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} +{$ENDIF} + +// Delphi XE2 (First FireMonkey and 64bit compiler) +{$IFDEF VER230} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} +{$ENDIF} + +// Delphi XE3 +{$IFDEF VER240} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} +{$ENDIF} + +// Delphi XE4 +{$IFDEF VER250} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} + {$DEFINE DELPHI18_UP} +{$ENDIF} + +// Delphi XE5 +{$IFDEF VER260} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} + {$DEFINE DELPHI18_UP} + {$DEFINE DELPHI19_UP} +{$ENDIF} + +// Delphi XE6 +{$IFDEF VER270} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} + {$DEFINE DELPHI18_UP} + {$DEFINE DELPHI19_UP} + {$DEFINE DELPHI20_UP} +{$ENDIF} + +// Delphi XE7 +{$IFDEF VER280} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} + {$DEFINE DELPHI18_UP} + {$DEFINE DELPHI19_UP} + {$DEFINE DELPHI20_UP} + {$DEFINE DELPHI21_UP} +{$ENDIF} + +// Delphi XE8 +{$IFDEF VER290} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} + {$DEFINE DELPHI18_UP} + {$DEFINE DELPHI19_UP} + {$DEFINE DELPHI20_UP} + {$DEFINE DELPHI21_UP} + {$DEFINE DELPHI22_UP} +{$ENDIF VER290} + +// Rad Studio 10 - Delphi Seattle +{$IFDEF VER300} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} + {$DEFINE DELPHI18_UP} + {$DEFINE DELPHI19_UP} + {$DEFINE DELPHI20_UP} + {$DEFINE DELPHI21_UP} + {$DEFINE DELPHI22_UP} + {$DEFINE DELPHI23_UP} +{$ENDIF} + +// Rad Studio 10.1 - Delphi Berlin +{$IFDEF VER310} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} + {$DEFINE DELPHI18_UP} + {$DEFINE DELPHI19_UP} + {$DEFINE DELPHI20_UP} + {$DEFINE DELPHI21_UP} + {$DEFINE DELPHI22_UP} + {$DEFINE DELPHI23_UP} + {$DEFINE DELPHI24_UP} +{$ENDIF} + +// Rad Studio 10.2 - Delphi Tokyo +{$IFDEF VER320} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} + {$DEFINE DELPHI18_UP} + {$DEFINE DELPHI19_UP} + {$DEFINE DELPHI20_UP} + {$DEFINE DELPHI21_UP} + {$DEFINE DELPHI22_UP} + {$DEFINE DELPHI23_UP} + {$DEFINE DELPHI24_UP} + {$DEFINE DELPHI25_UP} +{$ENDIF} + +// Rad Studio 10.3 - Delphi Rio +{$IFDEF VER330} + {$UNDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} + {$DEFINE DELPHI18_UP} + {$DEFINE DELPHI19_UP} + {$DEFINE DELPHI20_UP} + {$DEFINE DELPHI21_UP} + {$DEFINE DELPHI22_UP} + {$DEFINE DELPHI23_UP} + {$DEFINE DELPHI24_UP} + {$DEFINE DELPHI25_UP} + {$DEFINE DELPHI26_UP} +{$ENDIF} + +{$IFDEF FPC} + {$DEFINE SUPPORTS_INLINE} +{$ELSE} + {$IFDEF DELPHI_VERSION_UNKNOW} + {$DEFINE DELPHI5_UP} + {$DEFINE DELPHI6_UP} + {$DEFINE DELPHI7_UP} + {$DEFINE DELPHI8_UP} + {$DEFINE DELPHI9_UP} + {$DEFINE DELPHI10_UP} + {$DEFINE DELPHI11_UP} + {$DEFINE DELPHI12_UP} + {$DEFINE DELPHI14_UP} + {$DEFINE DELPHI15_UP} + {$DEFINE DELPHI16_UP} + {$DEFINE DELPHI17_UP} + {$DEFINE DELPHI18_UP} + {$DEFINE DELPHI19_UP} + {$DEFINE DELPHI20_UP} + {$DEFINE DELPHI21_UP} + {$DEFINE DELPHI22_UP} + {$DEFINE DELPHI23_UP} + {$DEFINE DELPHI24_UP} + {$DEFINE DELPHI25_UP} + {$DEFINE DELPHI26_UP} + {$ENDIF} +{$ENDIF} + +{$IFDEF DELPHI9_UP} + {$DEFINE SUPPORTS_INLINE} +{$ENDIF} + diff --git a/demos/Lazarus/TabbedBrowser2/uBrowserFrame.lfm b/demos/Lazarus/TabbedBrowser2/uBrowserFrame.lfm new file mode 100644 index 00000000..d447cc8c --- /dev/null +++ b/demos/Lazarus/TabbedBrowser2/uBrowserFrame.lfm @@ -0,0 +1,217 @@ +object BrowserFrame: TBrowserFrame + Left = 0 + Height = 670 + Top = 0 + Width = 932 + ClientHeight = 670 + ClientWidth = 932 + TabOrder = 0 + DesignLeft = 269 + DesignTop = 169 + object NavControlPnl: TPanel + Left = 0 + Height = 28 + Top = 0 + Width = 932 + Align = alTop + BevelOuter = bvNone + ClientHeight = 28 + ClientWidth = 932 + Enabled = False + TabOrder = 0 + object NavButtonPnl: TPanel + Left = 0 + Height = 28 + Top = 0 + Width = 123 + Align = alLeft + BevelOuter = bvNone + ClientHeight = 28 + ClientWidth = 123 + TabOrder = 0 + object BackBtn: TButton + Left = 0 + Height = 25 + Top = 0 + Width = 25 + Caption = '3' + Font.CharSet = SYMBOL_CHARSET + Font.Color = clWindowText + Font.Height = -19 + Font.Name = 'Webdings' + OnClick = BackBtnClick + ParentFont = False + TabOrder = 0 + end + object ForwardBtn: TButton + Left = 30 + Height = 25 + Top = 0 + Width = 25 + Caption = '4' + Font.CharSet = SYMBOL_CHARSET + Font.Color = clWindowText + Font.Height = -19 + Font.Name = 'Webdings' + OnClick = ForwardBtnClick + ParentFont = False + TabOrder = 1 + end + object ReloadBtn: TButton + Left = 59 + Height = 25 + Top = 0 + Width = 25 + Caption = 'q' + Font.CharSet = SYMBOL_CHARSET + Font.Color = clWindowText + Font.Height = -19 + Font.Name = 'Webdings' + OnClick = ReloadBtnClick + ParentFont = False + TabOrder = 2 + end + object StopBtn: TButton + Left = 88 + Height = 25 + Top = 0 + Width = 25 + Caption = '=' + Font.CharSet = SYMBOL_CHARSET + Font.Color = clWindowText + Font.Height = -19 + Font.Name = 'Webdings' + OnClick = StopBtnClick + ParentFont = False + TabOrder = 3 + end + end + object URLEditPnl: TPanel + Left = 123 + Height = 28 + Top = 0 + Width = 774 + Align = alClient + BevelOuter = bvNone + ClientHeight = 28 + ClientWidth = 774 + TabOrder = 1 + object URLCbx: TComboBox + Left = 0 + Height = 23 + Top = 1 + Width = 774 + Anchors = [akTop, akLeft, akRight] + ItemHeight = 15 + ItemIndex = 0 + Items.Strings = ( + 'https://www.google.com' + 'https://www.whatismybrowser.com/detect/what-http-headers-is-my-browser-sending' + 'https://www.w3schools.com/js/tryit.asp?filename=tryjs_win_close' + 'https://www.w3schools.com/js/tryit.asp?filename=tryjs_alert' + 'https://www.w3schools.com/js/tryit.asp?filename=tryjs_loc_assign' + 'https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_style_backgroundcolor' + 'https://www.w3schools.com/html/html5_video.asp' + 'http://www.adobe.com/software/flash/about/' + 'http://isflashinstalled.com/' + 'https://helpx.adobe.com/flash-player.html' + 'https://www.ultrasounds.com/' + 'https://www.whatismybrowser.com/detect/is-flash-installed' + 'http://html5test.com/' + 'https://webrtc.github.io/samples/src/content/devices/input-output/' + 'https://test.webrtc.org/' + 'https://www.w3schools.com/' + 'http://webglsamples.org/' + 'https://get.webgl.org/' + 'https://www.briskbard.com' + 'https://www.youtube.com' + 'https://html5demos.com/drag/' + 'https://developers.google.com/maps/documentation/javascript/examples/streetview-embed?hl=fr' + 'https://www.w3schools.com/Tags/tryit.asp?filename=tryhtml_iframe_name' + 'http://www-db.deis.unibo.it/courses/TW/DOCS/w3schools/html/tryit.asp-filename=tryhtml5_html_manifest.html' + 'https://www.browserleaks.com/webrtc' + 'https://frames-per-second.appspot.com/' + 'chrome://version/' + 'chrome://net-internals/' + 'chrome://tracing/' + 'chrome://appcache-internals/' + 'chrome://blob-internals/' + 'chrome://view-http-cache/' + 'chrome://credits/' + 'chrome://histograms/' + 'chrome://media-internals/' + 'chrome://kill' + 'chrome://crash' + 'chrome://hang' + 'chrome://shorthang' + 'chrome://gpuclean' + 'chrome://gpucrash' + 'chrome://gpuhang' + 'chrome://extensions-support' + 'chrome://process-internals' + ) + TabOrder = 0 + Text = 'https://www.google.com' + end + end + object ConfigPnl: TPanel + Left = 897 + Height = 28 + Top = 0 + Width = 35 + Align = alRight + BevelOuter = bvNone + ClientHeight = 28 + ClientWidth = 35 + TabOrder = 2 + object GoBtn: TButton + Left = 5 + Height = 25 + Top = 0 + Width = 25 + Caption = 'â–º' + Font.CharSet = ANSI_CHARSET + Font.Color = clWindowText + Font.Height = -17 + Font.Name = 'Arial' + Font.Style = [fsBold] + OnClick = GoBtnClick + ParentFont = False + TabOrder = 0 + end + end + end + object StatusBar1: TStatusBar + Left = 0 + Height = 23 + Top = 647 + Width = 932 + Panels = < + item + Width = 500 + end> + SimplePanel = False + end + object CEFWindowParent1: TCEFWindowParent + Left = 0 + Height = 619 + Top = 28 + Width = 932 + Align = alClient + TabOrder = 2 + end + object Chromium1: TChromium + OnLoadError = Chromium1LoadError + OnLoadingStateChange = Chromium1LoadingStateChange + OnAddressChange = Chromium1AddressChange + OnTitleChange = Chromium1TitleChange + OnStatusMessage = Chromium1StatusMessage + OnBeforePopup = Chromium1BeforePopup + OnAfterCreated = Chromium1AfterCreated + OnBeforeClose = Chromium1BeforeClose + OnClose = Chromium1Close + OnOpenUrlFromTab = Chromium1OpenUrlFromTab + left = 40 + top = 72 + end +end diff --git a/demos/Lazarus/TabbedBrowser2/uBrowserFrame.pas b/demos/Lazarus/TabbedBrowser2/uBrowserFrame.pas new file mode 100644 index 00000000..8448b518 --- /dev/null +++ b/demos/Lazarus/TabbedBrowser2/uBrowserFrame.pas @@ -0,0 +1,281 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2020 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest <hgourvest@gmail.com> + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uBrowserFrame; + +{$MODE Delphi} + +{$I cef.inc} + +interface + +uses + LCLIntf, LCLType, LMessages, Messages, SysUtils, Variants, + Classes, Graphics, Controls, Forms, Dialogs, + ExtCtrls, ComCtrls, StdCtrls, + uCEFWinControl, uCEFWindowParent, uCEFChromiumCore, uCEFChromium, + uCEFInterfaces, uCEFTypes, uCEFConstants; + +type + TBrowserTitleEvent = procedure(Sender: TObject; const aTitle : string) of object; + + TBrowserFrame = class(TFrame) + NavControlPnl: TPanel; + NavButtonPnl: TPanel; + BackBtn: TButton; + ForwardBtn: TButton; + ReloadBtn: TButton; + StopBtn: TButton; + URLEditPnl: TPanel; + URLCbx: TComboBox; + ConfigPnl: TPanel; + GoBtn: TButton; + StatusBar1: TStatusBar; + Chromium1: TChromium; + CEFWindowParent1: TCEFWindowParent; + + procedure Chromium1AfterCreated(Sender: TObject; const browser: ICefBrowser); + procedure Chromium1AddressChange(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const url: ustring); + procedure Chromium1BeforeClose(Sender: TObject; const browser: ICefBrowser); + procedure Chromium1Close(Sender: TObject; const browser: ICefBrowser; var aAction: TCefCloseBrowserAction); + procedure Chromium1LoadError(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; errorCode: Integer; const errorText, failedUrl: ustring); + procedure Chromium1LoadingStateChange(Sender: TObject; const browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean); + procedure Chromium1StatusMessage(Sender: TObject; const browser: ICefBrowser; const value: ustring); + procedure Chromium1TitleChange(Sender: TObject; const browser: ICefBrowser; const title: ustring); + procedure Chromium1BeforePopup(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 Chromium1OpenUrlFromTab(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; out Result: Boolean); + + procedure BackBtnClick(Sender: TObject); + procedure ForwardBtnClick(Sender: TObject); + procedure ReloadBtnClick(Sender: TObject); + procedure StopBtnClick(Sender: TObject); + procedure GoBtnClick(Sender: TObject); + + protected + FClosing : boolean; // Indicates that this frame is destroying the browser + FHomepage : string; + FOnBrowserDestroyed : TNotifyEvent; + FOnBrowserTitleChange : TBrowserTitleEvent; + + procedure BrowserCreatedMsg(var aMessage : TMessage); message CEF_AFTERCREATED; + procedure BrowserDestroyMsg(var aMessage : TMessage); message CEF_DESTROY; + + public + constructor Create(AOwner : TComponent); override; + procedure NotifyMoveOrResizeStarted; + procedure CreateBrowser; + procedure CloseBrowser; + + 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; + end; + +implementation + +{$R *.lfm} + +constructor TBrowserFrame.Create(AOwner : TComponent); +begin + inherited Create(AOwner); + + FClosing := False; + FHomepage := ''; + FOnBrowserDestroyed := nil; + FOnBrowserTitleChange := nil; +end; + +procedure TBrowserFrame.NotifyMoveOrResizeStarted; +begin + Chromium1.NotifyMoveOrResizeStarted; +end; + +procedure TBrowserFrame.ReloadBtnClick(Sender: TObject); +begin + Chromium1.Reload; +end; + +procedure TBrowserFrame.StopBtnClick(Sender: TObject); +begin + Chromium1.StopLoad; +end; + +procedure TBrowserFrame.CreateBrowser; +begin + Chromium1.DefaultURL := FHomepage; + Chromium1.CreateBrowser(CEFWindowParent1); +end; + +procedure TBrowserFrame.CloseBrowser; +begin + if not(FClosing) then + begin + FClosing := True; + NavControlPnl.Enabled := False; + Chromium1.CloseBrowser(True); + end; +end; + +procedure TBrowserFrame.ForwardBtnClick(Sender: TObject); +begin + Chromium1.GoForward; +end; + +procedure TBrowserFrame.GoBtnClick(Sender: TObject); +begin + Chromium1.LoadURL(URLCbx.Text); +end; + +procedure TBrowserFrame.Chromium1AfterCreated(Sender: TObject; + const browser: ICefBrowser); +begin + PostMessage(Handle, CEF_AFTERCREATED, 0, 0); +end; + +procedure TBrowserFrame.BackBtnClick(Sender: TObject); +begin + Chromium1.GoBack; +end; + +procedure TBrowserFrame.Chromium1AddressChange(Sender: TObject; + const browser: ICefBrowser; const frame: ICefFrame; const url: ustring); +begin + if (URLCbx.Items.IndexOf(url) < 0) then URLCbx.Items.Add(url); + + URLCbx.Text := url; +end; + +procedure TBrowserFrame.Chromium1BeforeClose(Sender: TObject; + const browser: ICefBrowser); +begin + if assigned(FOnBrowserDestroyed) then FOnBrowserDestroyed(self); +end; + +procedure TBrowserFrame.Chromium1BeforePopup(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.Chromium1Close(Sender: TObject; + const browser: ICefBrowser; var aAction: TCefCloseBrowserAction); +begin + PostMessage(Handle, CEF_DESTROY, 0, 0); + aAction := cbaDelay; +end; + +procedure TBrowserFrame.Chromium1LoadError(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>'; + + Chromium1.LoadString(TempString, frame); +end; + +procedure TBrowserFrame.Chromium1LoadingStateChange(Sender: TObject; + const browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean); +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; + +procedure TBrowserFrame.Chromium1OpenUrlFromTab(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.Chromium1StatusMessage(Sender: TObject; + const browser: ICefBrowser; const value: ustring); +begin + StatusBar1.Panels[0].Text := value; +end; + +procedure TBrowserFrame.Chromium1TitleChange(Sender: TObject; + const browser: ICefBrowser; const title: ustring); +begin + if not(assigned(FOnBrowserTitleChange)) then exit; + + if (length(title) > 0) then + FOnBrowserTitleChange(self, title) + else + FOnBrowserTitleChange(self, Chromium1.DocumentURL); +end; + +procedure TBrowserFrame.BrowserCreatedMsg(var aMessage : TMessage); +begin + CEFWindowParent1.UpdateSize; + NavControlPnl.Enabled := True; +end; + +procedure TBrowserFrame.BrowserDestroyMsg(var aMessage : TMessage); +begin + CEFWindowParent1.Free; +end; + +end. + + diff --git a/demos/Lazarus/TabbedBrowser2/uBrowserTab.pas b/demos/Lazarus/TabbedBrowser2/uBrowserTab.pas new file mode 100644 index 00000000..5692897f --- /dev/null +++ b/demos/Lazarus/TabbedBrowser2/uBrowserTab.pas @@ -0,0 +1,149 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2020 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest <hgourvest@gmail.com> + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uBrowserTab; + +{$MODE Delphi} + +{$I cef.inc} + +interface + +uses + LCLIntf, LCLType, LMessages, Classes, Messages, ComCtrls, Controls, + Forms, + uBrowserFrame; + +type + TBrowserTab = class(TTabSheet) + protected + FBrowserFrame : TBrowserFrame; + FTabID : cardinal; + + function GetParentForm : TCustomForm; + + function PostFormMessage(aMsg : cardinal; wParam : cardinal = 0; lParam : integer = 0) : boolean; + + procedure BrowserFrame_OnBrowserDestroyed(Sender: TObject); + procedure BrowserFrame_OnBrowserTitleChange(Sender: TObject; const aTitle : string); + + property ParentForm : TCustomForm read GetParentForm; + + public + constructor Create(AOwner: TComponent; aTabID : cardinal; const aCaption : string); reintroduce; + procedure NotifyMoveOrResizeStarted; + procedure CreateBrowser(const aHomepage : string); + procedure CloseBrowser; + + property TabID : cardinal read FTabID; + end; + +implementation + +uses + uMainForm; + +constructor TBrowserTab.Create(AOwner: TComponent; aTabID : cardinal; const aCaption : string); +begin + inherited Create(AOwner); + + FTabID := aTabID; + Caption := aCaption; + FBrowserFrame := nil; +end; + +function TBrowserTab.GetParentForm : TCustomForm; +var + TempParent : TWinControl; +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.HandleAllocated and + PostMessage(TempForm.Handle, aMsg, wParam, lParam); +end; + +procedure TBrowserTab.NotifyMoveOrResizeStarted; +begin + FBrowserFrame.NotifyMoveOrResizeStarted; +end; + +procedure TBrowserTab.CreateBrowser(const aHomepage : string); +begin + FBrowserFrame := TBrowserFrame.Create(self); + FBrowserFrame.Parent := self; + FBrowserFrame.Align := alClient; + FBrowserFrame.Visible := True; + FBrowserFrame.Homepage := aHomepage; + FBrowserFrame.OnBrowserDestroyed := BrowserFrame_OnBrowserDestroyed; + FBrowserFrame.OnBrowserTitleChange := BrowserFrame_OnBrowserTitleChange; + + FBrowserFrame.CreateBrowser; +end; + +procedure TBrowserTab.CloseBrowser; +begin + if (FBrowserFrame <> nil) then FBrowserFrame.CloseBrowser; +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 + Caption := aTitle; +end; + +end. diff --git a/demos/Lazarus/TabbedBrowser2/uMainForm.lfm b/demos/Lazarus/TabbedBrowser2/uMainForm.lfm new file mode 100644 index 00000000..60b0ca46 --- /dev/null +++ b/demos/Lazarus/TabbedBrowser2/uMainForm.lfm @@ -0,0 +1,62 @@ +object MainForm: TMainForm + Left = 357 + Height = 704 + Top = 89 + Width = 991 + Caption = 'Initializing. Please, wait...' + ClientHeight = 704 + ClientWidth = 991 + Color = clBtnFace + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + OnCloseQuery = FormCloseQuery + OnCreate = FormCreate + OnShow = FormShow + Position = poScreenCenter + LCLVersion = '2.0.6.0' + object BrowserPageCtrl: TPageControl + Left = 34 + Height = 704 + Top = 0 + Width = 957 + Align = alClient + TabOrder = 0 + end + object ButtonPnl: TPanel + Left = 0 + Height = 704 + Top = 0 + Width = 34 + Align = alLeft + BevelOuter = bvNone + ClientHeight = 704 + ClientWidth = 34 + Enabled = False + TabOrder = 1 + object AddTabBtn: TSpeedButton + Left = 4 + Height = 26 + Top = 4 + Width = 26 + Caption = '+' + Font.Color = clWindowText + Font.Height = -24 + Font.Name = 'Arial Black' + OnClick = AddTabBtnClick + ParentFont = False + end + object RemoveTabBtn: TSpeedButton + Left = 4 + Height = 26 + Top = 33 + Width = 26 + Caption = '−' + Font.Color = clWindowText + Font.Height = -24 + Font.Name = 'Arial Black' + OnClick = RemoveTabBtnClick + ParentFont = False + end + end +end diff --git a/demos/Lazarus/TabbedBrowser2/uMainForm.pas b/demos/Lazarus/TabbedBrowser2/uMainForm.pas new file mode 100644 index 00000000..e58da2be --- /dev/null +++ b/demos/Lazarus/TabbedBrowser2/uMainForm.pas @@ -0,0 +1,314 @@ +// ************************************************************************ +// ***************************** CEF4Delphi ******************************* +// ************************************************************************ +// +// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based +// browser in Delphi applications. +// +// The original license of DCEF3 still applies to CEF4Delphi. +// +// For more information about CEF4Delphi visit : +// https://www.briskbard.com/index.php?lang=en&pageid=cef +// +// Copyright © 2020 Salvador Diaz Fau. All rights reserved. +// +// ************************************************************************ +// ************ vvvv Original license and comments below vvvv ************* +// ************************************************************************ +(* + * Delphi Chromium Embedded 3 + * + * Usage allowed under the restrictions of the Lesser GNU General Public License + * or alternatively the restrictions of the Mozilla Public License 1.1 + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for + * the specific language governing rights and limitations under the License. + * + * Unit owner : Henri Gourvest <hgourvest@gmail.com> + * Web site : http://www.progdigy.com + * Repository : http://code.google.com/p/delphichromiumembedded/ + * Group : http://groups.google.com/group/delphichromiumembedded + * + * Embarcadero Technologies, Inc is not permitted to use or redistribute + * this source code without explicit permission. + * + *) + +unit uMainForm; + +{$MODE Delphi} + +{$I cef.inc} + +interface + +uses + LCLIntf, LCLType, LMessages, Messages, SysUtils, Variants, Classes, Graphics, + Controls, Forms, Dialogs, ComCtrls, ToolWin, Buttons, ExtCtrls, + uCEFApplication, uCEFTypes, uCEFConstants; + +const + CEF_INITIALIZED = WM_APP + $100; + CEF_DESTROYTAB = WM_APP + $101; + + HOMEPAGE_URL = 'https://www.google.com'; + DEFAULT_TAB_CAPTION = 'New tab'; + +type + TMainForm = class(TForm) + BrowserPageCtrl: TPageControl; + ButtonPnl: TPanel; + AddTabBtn: TSpeedButton; + RemoveTabBtn: TSpeedButton; + + procedure AddTabBtnClick(Sender: TObject); + procedure RemoveTabBtnClick(Sender: TObject); + + procedure FormShow(Sender: TObject); + procedure FormCreate(Sender: TObject); + procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); + + 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 + + function GetNextTabID : cardinal; + + procedure EnableButtonPnl; + function CloseAllTabs : boolean; + procedure CloseTab(aIndex : integer); + + procedure CEFInitializedMsg(var aMessage : TMessage); message CEF_INITIALIZED; + procedure DestroyTabMsg(var aMessage : TMessage); message CEF_DESTROYTAB; + procedure WMMove(var aMessage : TWMMove); message WM_MOVE; + procedure WMMoving(var aMessage : TMessage); message WM_MOVING; + procedure WMEnterMenuLoop(var aMessage: TMessage); message WM_ENTERMENULOOP; + procedure WMExitMenuLoop(var aMessage: TMessage); message WM_EXITMENULOOP; + + property NextTabID : cardinal read GetNextTabID; + end; + +var + MainForm: TMainForm; + +procedure CreateGlobalCEFApp; + +implementation + +{$R *.lfm} + +uses + uBrowserTab; + +// This demo shows how to use a TPageControl with TFrames that include +// CEF4Delphi browsers. + +// Instead of a regular TTabSheet we use a custom TBrowserTab class that +// inherits from TTabSheet 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 free it. + +// TBrowserFrame has all the usual code to close CEF4Delphi browsers following +// a similar destruction sequence than the MiniBrowser demo : +// +// 1. TBrowserTab.CloseBrowser calls TChromium.CloseBrowser which triggers the +// TChromium.OnClose event. +// 2. TChromium.OnClose sends a CEF_DESTROY 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 TPageControl has no tabs then we can set FCanClose to TRUE and send a +// WM_CLOSE to the main form to close the application. + +procedure GlobalCEFApp_OnContextInitialized; +begin + if (MainForm <> nil) and MainForm.HandleAllocated then + PostMessage(MainForm.Handle, CEF_INITIALIZED, 0, 0); +end; + +procedure CreateGlobalCEFApp; +begin + GlobalCEFApp := TCefApplication.Create; + GlobalCEFApp.cache := 'cache'; + GlobalCEFApp.OnContextInitialized := GlobalCEFApp_OnContextInitialized; +end; + +procedure TMainForm.EnableButtonPnl; +begin + if not(ButtonPnl.Enabled) then + begin + ButtonPnl.Enabled := True; + Caption := 'Tabbed Browser 2'; + cursor := crDefault; + if (BrowserPageCtrl.PageCount = 0) then AddTabBtn.Click; + end; +end; + +function TMainForm.GetNextTabID : cardinal; +begin + inc(FLastTabID); + Result := FLastTabID; +end; + +procedure TMainForm.AddTabBtnClick(Sender: TObject); +var + TempNewTab : TBrowserTab; +begin + TempNewTab := TBrowserTab.Create(self, NextTabID, DEFAULT_TAB_CAPTION); + TempNewTab.PageControl := BrowserPageCtrl; + + BrowserPageCtrl.ActivePageIndex := pred(BrowserPageCtrl.PageCount); + + TempNewTab.CreateBrowser(HOMEPAGE_URL); +end; + +procedure TMainForm.CEFInitializedMsg(var aMessage : TMessage); +begin + EnableButtonPnl; +end; + +procedure TMainForm.DestroyTabMsg(var aMessage : TMessage); +var + i : integer; + TempTab : TBrowserTab; +begin + i := 0; + while (i < BrowserPageCtrl.PageCount) do + begin + TempTab := TBrowserTab(BrowserPageCtrl.Pages[i]); + + if (TempTab.TabID = aMessage.wParam) then + begin + TempTab.Free; + break; + end + else + inc(i); + end; + + if FClosing and (BrowserPageCtrl.PageCount = 0) then + begin + FCanClose := True; + PostMessage(Handle, WM_CLOSE, 0, 0); + end; +end; + +procedure TMainForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean); +begin + CanClose := FCanClose; + + if not(FClosing) then + begin + FClosing := True; + ButtonPnl.Enabled := False; + + if not(CloseAllTabs) then + begin + FCanClose := True; + PostMessage(Handle, WM_CLOSE, 0, 0); + end; + end; +end; + +procedure TMainForm.FormCreate(Sender: TObject); +begin + FCanClose := False; + FClosing := False; + FLastTabID := 0; +end; + +procedure TMainForm.FormShow(Sender: TObject); +begin + if (GlobalCEFApp <> nil) and GlobalCEFApp.GlobalContextInitialized then + EnableButtonPnl; +end; + +procedure TMainForm.RemoveTabBtnClick(Sender: TObject); +begin + CloseTab(BrowserPageCtrl.ActivePageIndex); +end; + +function TMainForm.CloseAllTabs : boolean; +var + i : integer; +begin + Result := False; + i := pred(BrowserPageCtrl.PageCount); + + while (i >= 0) do + begin + TBrowserTab(BrowserPageCtrl.Pages[i]).CloseBrowser; + Result := True; + dec(i); + end; +end; + +procedure TMainForm.CloseTab(aIndex : integer); +begin + if (aIndex >= 0) and (aIndex < BrowserPageCtrl.PageCount) then + TBrowserTab(BrowserPageCtrl.Pages[aIndex]).CloseBrowser; +end; + +procedure TMainForm.WMMove(var aMessage : TWMMove); +var + i : integer; +begin + inherited; + + i := 0; + while (i < BrowserPageCtrl.PageCount) do + begin + TBrowserTab(BrowserPageCtrl.Pages[i]).NotifyMoveOrResizeStarted; + inc(i); + end; +end; + +procedure TMainForm.WMMoving(var aMessage : TMessage); +var + i : integer; +begin + inherited; + + i := 0; + while (i < BrowserPageCtrl.PageCount) do + begin + TBrowserTab(BrowserPageCtrl.Pages[i]).NotifyMoveOrResizeStarted; + inc(i); + end; +end; + +procedure TMainForm.WMEnterMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then + GlobalCEFApp.OsmodalLoop := True; +end; + +procedure TMainForm.WMExitMenuLoop(var aMessage: TMessage); +begin + inherited; + + if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then + GlobalCEFApp.OsmodalLoop := False; +end; + +end. diff --git a/update_CEF4Delphi.json b/update_CEF4Delphi.json index fc6affe4..07828095 100644 --- a/update_CEF4Delphi.json +++ b/update_CEF4Delphi.json @@ -2,7 +2,7 @@ "UpdateLazPackages" : [ { "ForceNotify" : true, - "InternalVersion" : 96, + "InternalVersion" : 97, "Name" : "cef4delphi_lazarus.lpk", "Version" : "79.1.36.0" }