mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2024-11-24 08:02:15 +02:00
Added: Demo BrowserWindowEx (Lazarus_any_OS) - with more than one browser
This commit is contained in:
parent
d37e72c010
commit
ac1f570c7b
BIN
demos/Lazarus_any_OS/BrowserWindowEx/BrowserWindowEx.ico
Normal file
BIN
demos/Lazarus_any_OS/BrowserWindowEx/BrowserWindowEx.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 134 KiB |
86
demos/Lazarus_any_OS/BrowserWindowEx/BrowserWindowEx.lpi
Normal file
86
demos/Lazarus_any_OS/BrowserWindowEx/BrowserWindowEx.lpi
Normal file
@ -0,0 +1,86 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="12"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<CompatibilityMode Value="True"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<Title Value="BrowserWindowEx"/>
|
||||
<Scaled Value="True"/>
|
||||
<ResourceType Value="res"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
<XPManifest>
|
||||
<DpiAware Value="True"/>
|
||||
</XPManifest>
|
||||
<Icon Value="0"/>
|
||||
</General>
|
||||
<BuildModes Count="1">
|
||||
<Item1 Name="Default" Default="True"/>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<DestinationDirectory Value="B:/laz_other/CEF4Delphi/demos/Lazarus_any_OS/BrowserWindowEx"/>
|
||||
<CompressFinally Value="False"/>
|
||||
<UseFileFilters Value="True"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<FormatVersion Value="2"/>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="2">
|
||||
<Item1>
|
||||
<PackageName Value="CEF4Delphi_Lazarus"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item2>
|
||||
</RequiredPackages>
|
||||
<Units Count="4">
|
||||
<Unit0>
|
||||
<Filename Value="BrowserWindowEx.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="uBrowserWindowEx.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="Form1"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
</Unit1>
|
||||
<Unit2>
|
||||
<Filename Value="initsubprocess.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="InitSubProcess"/>
|
||||
</Unit2>
|
||||
<Unit3>
|
||||
<Filename Value="globalcefapplication.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="GlobalCefApplication"/>
|
||||
</Unit3>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<Target>
|
||||
<Filename Value="../../../bin/BrowserWindowEx"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<DebugInfoType Value="dsDwarf3"/>
|
||||
</Debugging>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
<Other>
|
||||
<CustomOptions Value="-dUseCthreads"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
</CONFIG>
|
83
demos/Lazarus_any_OS/BrowserWindowEx/BrowserWindowEx.lpr
Normal file
83
demos/Lazarus_any_OS/BrowserWindowEx/BrowserWindowEx.lpr
Normal file
@ -0,0 +1,83 @@
|
||||
// ************************************************************************
|
||||
// ***************************** 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.
|
||||
*
|
||||
*)
|
||||
|
||||
|
||||
(*
|
||||
* Include the following files
|
||||
* BrowserWindowEx.app/Contents/Frameworks/ExternalPumpBrowser Helper.app/
|
||||
* files from the demos/Lazarus_Mac/AppHelper project
|
||||
* use create_mac_helper.sh
|
||||
*
|
||||
* BrowserWindowEx.app/Contents/Frameworks/Chromium Embedded Framework.framework
|
||||
* files from Release folder in cef download
|
||||
*
|
||||
*)
|
||||
|
||||
|
||||
program BrowserWindowEx;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
{$I cef.inc}
|
||||
|
||||
uses
|
||||
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||
cthreads,
|
||||
{$ENDIF}{$ENDIF}
|
||||
{$IFDEF LINUX}
|
||||
InitSubProcess, // On Linux this unit must be used *before* the "interfaces" unit.
|
||||
{$ENDIF}
|
||||
Interfaces,
|
||||
Forms,
|
||||
uBrowserWindowEx, GlobalCefApplication
|
||||
{ you can add units after this }
|
||||
;
|
||||
|
||||
{$R *.res}
|
||||
|
||||
{$IFDEF WIN32}
|
||||
// CEF needs to set the LARGEADDRESSAWARE ($20) flag which allows 32-bit processes to use up to 3GB of RAM.
|
||||
{$SetPEFlags $20}
|
||||
{$ENDIF}
|
||||
|
||||
begin
|
||||
RequireDerivedFormResource:=True;
|
||||
Application.Scaled := True;
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TForm1, Form1);
|
||||
Application.Run;
|
||||
end.
|
||||
|
BIN
demos/Lazarus_any_OS/BrowserWindowEx/BrowserWindowEx.res
Normal file
BIN
demos/Lazarus_any_OS/BrowserWindowEx/BrowserWindowEx.res
Normal file
Binary file not shown.
40
demos/Lazarus_any_OS/BrowserWindowEx/README.txt
Normal file
40
demos/Lazarus_any_OS/BrowserWindowEx/README.txt
Normal file
@ -0,0 +1,40 @@
|
||||
BrowserWindow
|
||||
|
||||
# ABOUT
|
||||
|
||||
This example uses
|
||||
TLazarusBrowserWindow
|
||||
TCEFWorkScheduler
|
||||
|
||||
TCEFWorkScheduler feeds the CEF messageloop by calling DoMessageLoopWork(). On Mac this is currently the only way to run the CEF messageloop.
|
||||
|
||||
|
||||
# SETUP
|
||||
|
||||
** Windows
|
||||
1) Download the CEF framework and place the content of the "Release" folder into the same folder as your exe.
|
||||
Alternatively you can point "GlobalCEFApp.FrameworkDirPath" to the location with the libraries.
|
||||
2) Run the project
|
||||
|
||||
** Linux
|
||||
1) Download the CEF framework and place the content of the "Release" folder into the same folder as your exe.
|
||||
Alternatively you can point "GlobalCEFApp.FrameworkDirPath" to the location with the libraries.
|
||||
2) Run the project
|
||||
|
||||
Note:
|
||||
- For your own Linux project you must modify the project source (lpr) and add "InitSubProcess" to the "uses" clause, so that it is in the list *before* the unit "Interfaces".
|
||||
- The call to "DestroyGlobalCEFApp" must be in a unit *not* used by "unit InitSubProcess" (including not used in any nested way).
|
||||
|
||||
|
||||
** Mac
|
||||
1) Go to "project options" and create the "App Bundle"
|
||||
2) Download the CEF framework and place the content of the "Release" folder into ExternalPumpBrowser.app/Contents/Frameworks/Chromium Embedded Framework.framework
|
||||
You should have:
|
||||
Chromium Embedded Framework
|
||||
Libraries/*
|
||||
Resources/*
|
||||
3) Open project "AppHelper", create App Bundle and compile the AppHelper.
|
||||
Run create_mac_helper.sh
|
||||
4) Open project ExternalPumpBrowser, compile and run
|
||||
|
||||
|
468
demos/Lazarus_any_OS/BrowserWindowEx/cef.inc
Normal file
468
demos/Lazarus_any_OS/BrowserWindowEx/cef.inc
Normal file
@ -0,0 +1,468 @@
|
||||
// ************************************************************************
|
||||
// ***************************** CEF4Delphi *******************************
|
||||
// ************************************************************************
|
||||
//
|
||||
// CEF4Delphi is based on DCEF3 which uses CEF3 to embed a chromium-based
|
||||
// browser in Delphi applications.
|
||||
//
|
||||
// The original license of DCEF3 still applies to CEF4Delphi.
|
||||
//
|
||||
// For more information about CEF4Delphi visit :
|
||||
// https://www.briskbard.com/index.php?lang=en&pageid=cef
|
||||
//
|
||||
// Copyright © 2017 Salvador Diaz Fau. All rights reserved.
|
||||
//
|
||||
// ************************************************************************
|
||||
// ************ vvvv Original license and comments below vvvv *************
|
||||
// ************************************************************************
|
||||
(*
|
||||
* Delphi Chromium Embedded 3
|
||||
*
|
||||
* Usage allowed under the restrictions of the Lesser GNU General Public License
|
||||
* or alternatively the restrictions of the Mozilla Public License 1.1
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
||||
* the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* Unit owner : Henri Gourvest <hgourvest@gmail.com>
|
||||
* Web site : http://www.progdigy.com
|
||||
* Repository : http://code.google.com/p/delphichromiumembedded/
|
||||
* Group : http://groups.google.com/group/delphichromiumembedded
|
||||
*
|
||||
* Embarcadero Technologies, Inc is not permitted to use or redistribute
|
||||
* this source code without explicit permission.
|
||||
*
|
||||
*)
|
||||
|
||||
// The complete list of compiler versions is here :
|
||||
// http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Compiler_Versions
|
||||
|
||||
{$DEFINE DELPHI_VERSION_UNKNOW}
|
||||
|
||||
// Delphi 5
|
||||
{$IFDEF VER130}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Delphi 6
|
||||
{$IFDEF VER140}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Delphi 7
|
||||
{$IFDEF VER150}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Delphi 8
|
||||
{$IFDEF VER160}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Delphi 2005
|
||||
{$IFDEF VER170}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF VER180}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
// Delphi 2007
|
||||
{$IFDEF VER185}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
// Delphi 2006
|
||||
{$ELSE}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
|
||||
// Delphi 2009
|
||||
{$IFDEF VER200}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$ENDIF}
|
||||
|
||||
//Delphi 2010
|
||||
{$IFDEF VER210}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Delphi XE
|
||||
{$IFDEF VER220}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$DEFINE DELPHI15_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Delphi XE2 (First FireMonkey and 64bit compiler)
|
||||
{$IFDEF VER230}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$DEFINE DELPHI15_UP}
|
||||
{$DEFINE DELPHI16_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Delphi XE3
|
||||
{$IFDEF VER240}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$DEFINE DELPHI15_UP}
|
||||
{$DEFINE DELPHI16_UP}
|
||||
{$DEFINE DELPHI17_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Delphi XE4
|
||||
{$IFDEF VER250}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$DEFINE DELPHI15_UP}
|
||||
{$DEFINE DELPHI16_UP}
|
||||
{$DEFINE DELPHI17_UP}
|
||||
{$DEFINE DELPHI18_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Delphi XE5
|
||||
{$IFDEF VER260}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$DEFINE DELPHI15_UP}
|
||||
{$DEFINE DELPHI16_UP}
|
||||
{$DEFINE DELPHI17_UP}
|
||||
{$DEFINE DELPHI18_UP}
|
||||
{$DEFINE DELPHI19_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Delphi XE6
|
||||
{$IFDEF VER270}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$DEFINE DELPHI15_UP}
|
||||
{$DEFINE DELPHI16_UP}
|
||||
{$DEFINE DELPHI17_UP}
|
||||
{$DEFINE DELPHI18_UP}
|
||||
{$DEFINE DELPHI19_UP}
|
||||
{$DEFINE DELPHI20_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Delphi XE7
|
||||
{$IFDEF VER280}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$DEFINE DELPHI15_UP}
|
||||
{$DEFINE DELPHI16_UP}
|
||||
{$DEFINE DELPHI17_UP}
|
||||
{$DEFINE DELPHI18_UP}
|
||||
{$DEFINE DELPHI19_UP}
|
||||
{$DEFINE DELPHI20_UP}
|
||||
{$DEFINE DELPHI21_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Delphi XE8
|
||||
{$IFDEF VER290}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$DEFINE DELPHI15_UP}
|
||||
{$DEFINE DELPHI16_UP}
|
||||
{$DEFINE DELPHI17_UP}
|
||||
{$DEFINE DELPHI18_UP}
|
||||
{$DEFINE DELPHI19_UP}
|
||||
{$DEFINE DELPHI20_UP}
|
||||
{$DEFINE DELPHI21_UP}
|
||||
{$DEFINE DELPHI22_UP}
|
||||
{$ENDIF VER290}
|
||||
|
||||
// Rad Studio 10 - Delphi Seattle
|
||||
{$IFDEF VER300}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$DEFINE DELPHI15_UP}
|
||||
{$DEFINE DELPHI16_UP}
|
||||
{$DEFINE DELPHI17_UP}
|
||||
{$DEFINE DELPHI18_UP}
|
||||
{$DEFINE DELPHI19_UP}
|
||||
{$DEFINE DELPHI20_UP}
|
||||
{$DEFINE DELPHI21_UP}
|
||||
{$DEFINE DELPHI22_UP}
|
||||
{$DEFINE DELPHI23_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Rad Studio 10.1 - Delphi Berlin
|
||||
{$IFDEF VER310}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$DEFINE DELPHI15_UP}
|
||||
{$DEFINE DELPHI16_UP}
|
||||
{$DEFINE DELPHI17_UP}
|
||||
{$DEFINE DELPHI18_UP}
|
||||
{$DEFINE DELPHI19_UP}
|
||||
{$DEFINE DELPHI20_UP}
|
||||
{$DEFINE DELPHI21_UP}
|
||||
{$DEFINE DELPHI22_UP}
|
||||
{$DEFINE DELPHI23_UP}
|
||||
{$DEFINE DELPHI24_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Rad Studio 10.2 - Delphi Tokyo
|
||||
{$IFDEF VER320}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$DEFINE DELPHI15_UP}
|
||||
{$DEFINE DELPHI16_UP}
|
||||
{$DEFINE DELPHI17_UP}
|
||||
{$DEFINE DELPHI18_UP}
|
||||
{$DEFINE DELPHI19_UP}
|
||||
{$DEFINE DELPHI20_UP}
|
||||
{$DEFINE DELPHI21_UP}
|
||||
{$DEFINE DELPHI22_UP}
|
||||
{$DEFINE DELPHI23_UP}
|
||||
{$DEFINE DELPHI24_UP}
|
||||
{$DEFINE DELPHI25_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Rad Studio 10.3 - Delphi Rio
|
||||
{$IFDEF VER330}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$DEFINE DELPHI15_UP}
|
||||
{$DEFINE DELPHI16_UP}
|
||||
{$DEFINE DELPHI17_UP}
|
||||
{$DEFINE DELPHI18_UP}
|
||||
{$DEFINE DELPHI19_UP}
|
||||
{$DEFINE DELPHI20_UP}
|
||||
{$DEFINE DELPHI21_UP}
|
||||
{$DEFINE DELPHI22_UP}
|
||||
{$DEFINE DELPHI23_UP}
|
||||
{$DEFINE DELPHI24_UP}
|
||||
{$DEFINE DELPHI25_UP}
|
||||
{$DEFINE DELPHI26_UP}
|
||||
{$ENDIF}
|
||||
|
||||
// Rad Studio 10.4 - Delphi Sydney
|
||||
{$IFDEF VER340}
|
||||
{$UNDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$DEFINE DELPHI15_UP}
|
||||
{$DEFINE DELPHI16_UP}
|
||||
{$DEFINE DELPHI17_UP}
|
||||
{$DEFINE DELPHI18_UP}
|
||||
{$DEFINE DELPHI19_UP}
|
||||
{$DEFINE DELPHI20_UP}
|
||||
{$DEFINE DELPHI21_UP}
|
||||
{$DEFINE DELPHI22_UP}
|
||||
{$DEFINE DELPHI23_UP}
|
||||
{$DEFINE DELPHI24_UP}
|
||||
{$DEFINE DELPHI25_UP}
|
||||
{$DEFINE DELPHI26_UP}
|
||||
{$DEFINE DELPHI27_UP}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF FPC}
|
||||
{$DEFINE SUPPORTS_INLINE}
|
||||
{$IF DEFINED(FPC_FULLVERSION) AND (FPC_FULLVERSION >= 30200)}
|
||||
{$DEFINE FPC_VER_320}
|
||||
{$IFEND}
|
||||
{$ELSE}
|
||||
{$IFDEF DELPHI_VERSION_UNKNOW}
|
||||
{$DEFINE DELPHI5_UP}
|
||||
{$DEFINE DELPHI6_UP}
|
||||
{$DEFINE DELPHI7_UP}
|
||||
{$DEFINE DELPHI8_UP}
|
||||
{$DEFINE DELPHI9_UP}
|
||||
{$DEFINE DELPHI10_UP}
|
||||
{$DEFINE DELPHI11_UP}
|
||||
{$DEFINE DELPHI12_UP}
|
||||
{$DEFINE DELPHI14_UP}
|
||||
{$DEFINE DELPHI15_UP}
|
||||
{$DEFINE DELPHI16_UP}
|
||||
{$DEFINE DELPHI17_UP}
|
||||
{$DEFINE DELPHI18_UP}
|
||||
{$DEFINE DELPHI19_UP}
|
||||
{$DEFINE DELPHI20_UP}
|
||||
{$DEFINE DELPHI21_UP}
|
||||
{$DEFINE DELPHI22_UP}
|
||||
{$DEFINE DELPHI23_UP}
|
||||
{$DEFINE DELPHI24_UP}
|
||||
{$DEFINE DELPHI25_UP}
|
||||
{$DEFINE DELPHI26_UP}
|
||||
{$DEFINE DELPHI27_UP}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF DELPHI9_UP}
|
||||
{$DEFINE SUPPORTS_INLINE}
|
||||
{$ENDIF}
|
||||
|
||||
{$IF DEFINED(CPUX32) OR
|
||||
DEFINED(CPU386) OR
|
||||
DEFINED(CPUi386) OR
|
||||
DEFINED(CPUPOWERPC32) OR
|
||||
DEFINED(CPUSPARC32) OR
|
||||
DEFINED(CPU32BITS) OR
|
||||
DEFINED(CPUARM32) OR
|
||||
DEFINED(WIN32) OR
|
||||
DEFINED(IOS32) OR
|
||||
DEFINED(MACOS32) OR
|
||||
DEFINED(LINUX32) OR
|
||||
DEFINED(POSIX32) OR
|
||||
DEFINED(ANDROID32)}
|
||||
{$DEFINE TARGET_32BITS}
|
||||
{$IFEND}
|
||||
|
||||
// Delphi uses MACOS for the new MacOSX and DARWIN is not defined
|
||||
// FPC uses DARWIN for the new MacOSX and MACOS is defined for the classic Macintosh OS (System 7)
|
||||
// We define MACOSX to avoid conflicts in both situations
|
||||
{$IFDEF FPC}
|
||||
{$IFDEF DARWIN}
|
||||
{$DEFINE MACOSX}
|
||||
{$ENDIF}
|
||||
{$ELSE}
|
||||
{$IFDEF MACOS}
|
||||
{$DEFINE MACOSX}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
13
demos/Lazarus_any_OS/BrowserWindowEx/create_mac_helper.sh
Normal file
13
demos/Lazarus_any_OS/BrowserWindowEx/create_mac_helper.sh
Normal file
@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
CDIR=$(pwd)
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
../AppHelper/create_mac_helper_apps.sh ../../../bin/BrowserWindowEx.app
|
||||
|
||||
if [ "$(grep -i TCrCocoaApplication ../../../bin/BrowserWindowEx.app/Contents/Info.plist)" = "" ];
|
||||
then
|
||||
sed -i '' "1,4s/<dict>/<dict>\n <key>NSPrincipalClass<\/key>\n <string>TCrCocoaApplication<\/string>/" ../../../bin/BrowserWindowEx.app/Contents/Info.plist
|
||||
fi
|
||||
|
||||
cd "$CDIR"
|
116
demos/Lazarus_any_OS/BrowserWindowEx/globalcefapplication.pas
Normal file
116
demos/Lazarus_any_OS/BrowserWindowEx/globalcefapplication.pas
Normal file
@ -0,0 +1,116 @@
|
||||
// ************************************************************************
|
||||
// ***************************** CEF4Delphi *******************************
|
||||
// ************************************************************************
|
||||
//
|
||||
// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based
|
||||
// browser in Delphi applications.
|
||||
//
|
||||
// The original license of DCEF3 still applies to CEF4Delphi.
|
||||
//
|
||||
// For more information about CEF4Delphi visit :
|
||||
// https://www.briskbard.com/index.php?lang=en&pageid=cef
|
||||
//
|
||||
// Copyright © 2021 Salvador Diaz Fau. All rights reserved.
|
||||
//
|
||||
// ************************************************************************
|
||||
// ************ vvvv Original license and comments below vvvv *************
|
||||
// ************************************************************************
|
||||
(*
|
||||
* Delphi Chromium Embedded 3
|
||||
*
|
||||
* Usage allowed under the restrictions of the Lesser GNU General Public License
|
||||
* or alternatively the restrictions of the Mozilla Public License 1.1
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
||||
* the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* Unit owner : Henri Gourvest <hgourvest@gmail.com>
|
||||
* Web site : http://www.progdigy.com
|
||||
* Repository : http://code.google.com/p/delphichromiumembedded/
|
||||
* Group : http://groups.google.com/group/delphichromiumembedded
|
||||
*
|
||||
* Embarcadero Technologies, Inc is not permitted to use or redistribute
|
||||
* this source code without explicit permission.
|
||||
*
|
||||
*)
|
||||
|
||||
unit GlobalCefApplication;
|
||||
|
||||
{$mode ObjFPC}{$H+}
|
||||
{$I cef.inc}
|
||||
|
||||
{.$DEFINE USE_MULTI_THREAD_LOOP} // Only Windows/Linux
|
||||
{.$DEFINE USE_APP_HELPER} // Optional on Windows/Linux
|
||||
|
||||
{$IFDEF MACOSX}
|
||||
{$UNDEF USE_MULTI_THREAD_LOOP} // Will fail on Mac
|
||||
{$DEFINE USE_APP_HELPER} // Required on Mac
|
||||
{$ENDIF}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
uCEFApplication, uCEFWorkScheduler, FileUtil;
|
||||
|
||||
procedure CreateGlobalCEFApp;
|
||||
|
||||
implementation
|
||||
|
||||
procedure GlobalCEFApp_OnScheduleMessagePumpWork(const aDelayMS : int64);
|
||||
begin
|
||||
if (GlobalCEFWorkScheduler <> nil) then GlobalCEFWorkScheduler.ScheduleMessagePumpWork(aDelayMS);
|
||||
end;
|
||||
|
||||
procedure CreateGlobalCEFApp;
|
||||
begin
|
||||
if GlobalCEFApp <> nil then
|
||||
exit;
|
||||
|
||||
{$IFnDEF USE_MULTI_THREAD_LOOP}
|
||||
// TCEFWorkScheduler will call cef_do_message_loop_work when
|
||||
// it's told in the GlobalCEFApp.OnScheduleMessagePumpWork event.
|
||||
// GlobalCEFWorkScheduler needs to be created before the
|
||||
// GlobalCEFApp.StartMainProcess call.
|
||||
GlobalCEFWorkScheduler := TCEFWorkScheduler.Create(nil);
|
||||
{$ENDIF}
|
||||
|
||||
GlobalCEFApp := TCefApplication.Create;
|
||||
{$IFDEF USE_MULTI_THREAD_LOOP}
|
||||
// On Windows/Linux CEF can use threads for the message-loop
|
||||
GlobalCEFApp.MultiThreadedMessageLoop := True;
|
||||
{$ELSE}
|
||||
// use External Pump for message-loop
|
||||
GlobalCEFApp.ExternalMessagePump := True;
|
||||
GlobalCEFApp.MultiThreadedMessageLoop := False;
|
||||
GlobalCEFApp.OnScheduleMessagePumpWork := @GlobalCEFApp_OnScheduleMessagePumpWork;
|
||||
{$ENDIF}
|
||||
|
||||
GlobalCEFApp.CheckCEFFiles := false;
|
||||
|
||||
{$IFnDEF MACOSX}
|
||||
{$IFDEF USE_APP_HELPER}
|
||||
(* Use AppHelper as subprocess, instead of the main exe *)
|
||||
GlobalCEFApp.BrowserSubprocessPath := 'AppHelper' + GetExeExt;
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF MACOSX}
|
||||
(* Enable the below to prevent being asked for permission to access "Chromium Safe Storage"
|
||||
If set to true, Cookies will not be encrypted.
|
||||
*)
|
||||
GlobalCEFApp.UseMockKeyChain := True;
|
||||
{$ENDIF}
|
||||
{$IFDEF LINUX}
|
||||
// This is a workaround for the 'GPU is not usable error' issue :
|
||||
// https://bitbucket.org/chromiumembedded/cef/issues/2964/gpu-is-not-usable-error-during-cef
|
||||
GlobalCEFApp.DisableZygote := True; // this property adds the "--no-zygote" command line switch
|
||||
{$ENDIF}
|
||||
{
|
||||
GlobalCEFApp.LogFile := 'cef.log';
|
||||
GlobalCEFApp.LogSeverity := LOGSEVERITY_VERBOSE;
|
||||
}
|
||||
end;
|
||||
|
||||
end.
|
||||
|
61
demos/Lazarus_any_OS/BrowserWindowEx/initsubprocess.pas
Normal file
61
demos/Lazarus_any_OS/BrowserWindowEx/initsubprocess.pas
Normal file
@ -0,0 +1,61 @@
|
||||
// ************************************************************************
|
||||
// ***************************** CEF4Delphi *******************************
|
||||
// ************************************************************************
|
||||
//
|
||||
// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based
|
||||
// browser in Delphi applications.
|
||||
//
|
||||
// The original license of DCEF3 still applies to CEF4Delphi.
|
||||
//
|
||||
// For more information about CEF4Delphi visit :
|
||||
// https://www.briskbard.com/index.php?lang=en&pageid=cef
|
||||
//
|
||||
// Copyright © 2021 Salvador Diaz Fau. All rights reserved.
|
||||
//
|
||||
// ************************************************************************
|
||||
// ************ vvvv Original license and comments below vvvv *************
|
||||
// ************************************************************************
|
||||
(*
|
||||
* Delphi Chromium Embedded 3
|
||||
*
|
||||
* Usage allowed under the restrictions of the Lesser GNU General Public License
|
||||
* or alternatively the restrictions of the Mozilla Public License 1.1
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
||||
* the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* Unit owner : Henri Gourvest <hgourvest@gmail.com>
|
||||
* Web site : http://www.progdigy.com
|
||||
* Repository : http://code.google.com/p/delphichromiumembedded/
|
||||
* Group : http://groups.google.com/group/delphichromiumembedded
|
||||
*
|
||||
* Embarcadero Technologies, Inc is not permitted to use or redistribute
|
||||
* this source code without explicit permission.
|
||||
*
|
||||
*)
|
||||
|
||||
unit InitSubProcess;
|
||||
|
||||
{$mode ObjFPC}{$H+}
|
||||
{$I cef.inc}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
GlobalCefApplication, uCEFApplication, uCEFWorkScheduler;
|
||||
|
||||
implementation
|
||||
|
||||
initialization
|
||||
CreateGlobalCEFApp;
|
||||
if not GlobalCEFApp.StartMainProcess then begin
|
||||
if GlobalCEFWorkScheduler <> nil then
|
||||
GlobalCEFWorkScheduler.StopScheduler;
|
||||
DestroyGlobalCEFApp;
|
||||
DestroyGlobalCEFWorkScheduler;
|
||||
halt(0); // exit the subprocess
|
||||
end;
|
||||
|
||||
end.
|
||||
|
245
demos/Lazarus_any_OS/BrowserWindowEx/uBrowserWindowEx.lfm
Normal file
245
demos/Lazarus_any_OS/BrowserWindowEx/uBrowserWindowEx.lfm
Normal file
@ -0,0 +1,245 @@
|
||||
object Form1: TForm1
|
||||
Left = 473
|
||||
Height = 589
|
||||
Top = 227
|
||||
Width = 967
|
||||
Caption = 'Initializing browser. Please wait...'
|
||||
ClientHeight = 589
|
||||
ClientWidth = 967
|
||||
OnCloseQuery = FormCloseQuery
|
||||
OnCreate = FormCreate
|
||||
Position = poScreenCenter
|
||||
LCLVersion = '2.1.0.0'
|
||||
object PanelLeft: TPanel
|
||||
Left = 0
|
||||
Height = 557
|
||||
Top = 32
|
||||
Width = 484
|
||||
Align = alLeft
|
||||
ClientHeight = 557
|
||||
ClientWidth = 484
|
||||
TabOrder = 0
|
||||
object AddressPnlLeft: TPanel
|
||||
Left = 1
|
||||
Height = 23
|
||||
Top = 1
|
||||
Width = 482
|
||||
Align = alTop
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 23
|
||||
ClientWidth = 482
|
||||
Enabled = False
|
||||
TabOrder = 0
|
||||
object GoBtnLeft: TButton
|
||||
Left = 424
|
||||
Height = 23
|
||||
Top = 0
|
||||
Width = 35
|
||||
Align = alRight
|
||||
Caption = 'Go'
|
||||
OnClick = GoBtnLeftClick
|
||||
TabOrder = 0
|
||||
end
|
||||
object AddressEdtLeft: TComboBox
|
||||
Left = 0
|
||||
Height = 23
|
||||
Top = 0
|
||||
Width = 424
|
||||
Align = alClient
|
||||
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/html/html5_video.asp'
|
||||
'http://www.adobe.com/software/flash/about/'
|
||||
'http://isflashinstalled.com/'
|
||||
'chrome://version/'
|
||||
'http://html5test.com/'
|
||||
'https://www.w3schools.com/'
|
||||
'http://webglsamples.org/'
|
||||
'https://get.webgl.org/'
|
||||
'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'
|
||||
'https://www.browserleaks.com/webrtc'
|
||||
'https://frames-per-second.appspot.com/'
|
||||
)
|
||||
TabOrder = 1
|
||||
Text = 'https://www.google.com'
|
||||
end
|
||||
object CloseBtnLeft: TSpeedButton
|
||||
Left = 459
|
||||
Height = 23
|
||||
Top = 0
|
||||
Width = 23
|
||||
Align = alRight
|
||||
Images = ImageList1
|
||||
ImageIndex = 0
|
||||
OnClick = CloseBtnLeftClick
|
||||
end
|
||||
end
|
||||
object OpenBtnLeft: TSpeedButton
|
||||
AnchorSideLeft.Control = PanelLeft
|
||||
AnchorSideLeft.Side = asrCenter
|
||||
AnchorSideTop.Control = PanelLeft
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 182
|
||||
Height = 70
|
||||
Top = 243
|
||||
Width = 120
|
||||
Caption = 'Open Browser'
|
||||
OnClick = OpenBtnLeftClick
|
||||
end
|
||||
end
|
||||
object Splitter1: TSplitter
|
||||
Left = 484
|
||||
Height = 557
|
||||
Top = 32
|
||||
Width = 5
|
||||
end
|
||||
object PanelRight: TPanel
|
||||
Left = 489
|
||||
Height = 557
|
||||
Top = 32
|
||||
Width = 478
|
||||
Align = alClient
|
||||
ClientHeight = 557
|
||||
ClientWidth = 478
|
||||
TabOrder = 2
|
||||
object AddressPnlRight: TPanel
|
||||
Left = 1
|
||||
Height = 23
|
||||
Top = 1
|
||||
Width = 476
|
||||
Align = alTop
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 23
|
||||
ClientWidth = 476
|
||||
Enabled = False
|
||||
TabOrder = 0
|
||||
object GoBtnRight: TButton
|
||||
Left = 418
|
||||
Height = 23
|
||||
Top = 0
|
||||
Width = 35
|
||||
Align = alRight
|
||||
Caption = 'Go'
|
||||
OnClick = GoBtnRightClick
|
||||
TabOrder = 0
|
||||
end
|
||||
object AddressEdtRight: TComboBox
|
||||
Left = 0
|
||||
Height = 23
|
||||
Top = 0
|
||||
Width = 418
|
||||
Align = alClient
|
||||
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/html/html5_video.asp'
|
||||
'http://www.adobe.com/software/flash/about/'
|
||||
'http://isflashinstalled.com/'
|
||||
'chrome://version/'
|
||||
'http://html5test.com/'
|
||||
'https://www.w3schools.com/'
|
||||
'http://webglsamples.org/'
|
||||
'https://get.webgl.org/'
|
||||
'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'
|
||||
'https://www.browserleaks.com/webrtc'
|
||||
'https://frames-per-second.appspot.com/'
|
||||
)
|
||||
TabOrder = 1
|
||||
Text = 'https://www.google.com'
|
||||
end
|
||||
object CloseBtnRight: TSpeedButton
|
||||
Left = 453
|
||||
Height = 23
|
||||
Top = 0
|
||||
Width = 23
|
||||
Align = alRight
|
||||
Images = ImageList1
|
||||
ImageIndex = 0
|
||||
OnClick = CloseBtnRightClick
|
||||
end
|
||||
end
|
||||
object OpenBtnRight: TSpeedButton
|
||||
AnchorSideLeft.Control = PanelRight
|
||||
AnchorSideLeft.Side = asrCenter
|
||||
AnchorSideTop.Control = PanelRight
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 179
|
||||
Height = 70
|
||||
Top = 243
|
||||
Width = 120
|
||||
Caption = 'Open Browser'
|
||||
OnClick = OpenBtnRightClick
|
||||
end
|
||||
end
|
||||
object Panel1: TPanel
|
||||
Left = 0
|
||||
Height = 32
|
||||
Top = 0
|
||||
Width = 967
|
||||
Align = alTop
|
||||
AutoSize = True
|
||||
ChildSizing.LeftRightSpacing = 5
|
||||
ChildSizing.TopBottomSpacing = 3
|
||||
ChildSizing.HorizontalSpacing = 10
|
||||
ChildSizing.VerticalSpacing = 3
|
||||
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
||||
ChildSizing.ControlsPerLine = 5
|
||||
ClientHeight = 32
|
||||
ClientWidth = 967
|
||||
TabOrder = 3
|
||||
object BtnCloseApp: TButton
|
||||
Left = 5
|
||||
Height = 25
|
||||
Top = 3
|
||||
Width = 80
|
||||
Caption = 'Close App'
|
||||
OnClick = BtnCloseAppClick
|
||||
TabOrder = 0
|
||||
end
|
||||
object BtnCloseForm: TButton
|
||||
Left = 95
|
||||
Height = 25
|
||||
Top = 3
|
||||
Width = 86
|
||||
Caption = 'Close Form'
|
||||
OnClick = BtnCloseFormClick
|
||||
TabOrder = 1
|
||||
end
|
||||
object BtnModal: TButton
|
||||
Left = 191
|
||||
Height = 25
|
||||
Top = 3
|
||||
Width = 92
|
||||
Caption = 'Show Modal'
|
||||
OnClick = BtnModalClick
|
||||
TabOrder = 2
|
||||
end
|
||||
end
|
||||
object ImageList1: TImageList
|
||||
left = 672
|
||||
top = 104
|
||||
Bitmap = {
|
||||
4C7A010000001000000010000000D70000000000000078DAE591CB0A82501445
|
||||
FD19C5C7F58DA2A0F8C2FFF2178BA0226C12A6A1627DC1E9EE410D1CA8E3BA70
|
||||
270716FBEC7504E1775E92BCCA3C6FC8B2A66C3ECFB22B99665B2CF160E3F841
|
||||
41D092A24C296661F82CD2B4E1B30B79DE9E9678E482759C9E5C77204D9BAA28
|
||||
6AC9F7917D20513C966B1D900BD63447DE6320DB6E48D7CF244975B1D503726D
|
||||
7B20C67ABEC39D7719ABAD2CFA6267E48255D58EFFDBD7C79A7FB8425FEC8C5C
|
||||
B09AD69061D424CB5DB6C4E346F00C579FBEC805CBD889CF778BFE715FDC68EE
|
||||
19B960B7F8FFB7F70660608313
|
||||
}
|
||||
end
|
||||
end
|
395
demos/Lazarus_any_OS/BrowserWindowEx/uBrowserWindowEx.pas
Normal file
395
demos/Lazarus_any_OS/BrowserWindowEx/uBrowserWindowEx.pas
Normal file
@ -0,0 +1,395 @@
|
||||
// ************************************************************************
|
||||
// ***************************** CEF4Delphi *******************************
|
||||
// ************************************************************************
|
||||
//
|
||||
// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based
|
||||
// browser in Delphi applications.
|
||||
//
|
||||
// The original license of DCEF3 still applies to CEF4Delphi.
|
||||
//
|
||||
// For more information about CEF4Delphi visit :
|
||||
// https://www.briskbard.com/index.php?lang=en&pageid=cef
|
||||
//
|
||||
// Copyright © 2021 Salvador Diaz Fau. All rights reserved.
|
||||
//
|
||||
// ************************************************************************
|
||||
// ************ vvvv Original license and comments below vvvv *************
|
||||
// ************************************************************************
|
||||
(*
|
||||
* Delphi Chromium Embedded 3
|
||||
*
|
||||
* Usage allowed under the restrictions of the Lesser GNU General Public License
|
||||
* or alternatively the restrictions of the Mozilla Public License 1.1
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
||||
* the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* Unit owner : Henri Gourvest <hgourvest@gmail.com>
|
||||
* Web site : http://www.progdigy.com
|
||||
* Repository : http://code.google.com/p/delphichromiumembedded/
|
||||
* Group : http://groups.google.com/group/delphichromiumembedded
|
||||
*
|
||||
* Embarcadero Technologies, Inc is not permitted to use or redistribute
|
||||
* this source code without explicit permission.
|
||||
*
|
||||
*)
|
||||
|
||||
unit uBrowserWindowEx;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
{$I cef.inc}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
GlobalCefApplication,
|
||||
uCEFLazarusCocoa, // required for Cocoa
|
||||
SysUtils, Messages, Forms, Controls,
|
||||
Dialogs, ExtCtrls, StdCtrls, LMessages, Buttons,
|
||||
uCEFTypes, uCEFInterfaces,
|
||||
uCEFWorkScheduler, uCEFLazarusBrowserWindow, Classes;
|
||||
|
||||
type
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
TForm1 = class(TForm)
|
||||
AddressEdtLeft: TComboBox;
|
||||
AddressEdtRight: TComboBox;
|
||||
AddressPnlRight: TPanel;
|
||||
BtnCloseApp: TButton;
|
||||
BtnCloseForm: TButton;
|
||||
BtnModal: TButton;
|
||||
GoBtnLeft: TButton;
|
||||
AddressPnlLeft: TPanel;
|
||||
GoBtnRight: TButton;
|
||||
ImageList1: TImageList;
|
||||
Panel1: TPanel;
|
||||
PanelRight: TPanel;
|
||||
PanelLeft: TPanel;
|
||||
CloseBtnLeft: TSpeedButton;
|
||||
CloseBtnRight: TSpeedButton;
|
||||
OpenBtnLeft: TSpeedButton;
|
||||
OpenBtnRight: TSpeedButton;
|
||||
Splitter1: TSplitter;
|
||||
|
||||
procedure BtnCloseAppClick(Sender: TObject);
|
||||
procedure BtnCloseFormClick(Sender: TObject);
|
||||
procedure BtnModalClick(Sender: TObject);
|
||||
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: Boolean; var Result: Boolean);
|
||||
procedure Chromium1OpenUrlFromTab(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const targetUrl: ustring; targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean; out Result: Boolean);
|
||||
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
|
||||
procedure OpenBtnLeftClick(Sender: TObject);
|
||||
procedure LeftBrowserCreated(Sender: TObject);
|
||||
procedure GoBtnLeftClick(Sender: TObject);
|
||||
procedure CloseBtnLeftClick(Sender: TObject);
|
||||
procedure LeftBrowserClosed(Sender: TObject);
|
||||
|
||||
procedure OpenBtnRightClick(Sender: TObject);
|
||||
procedure RightBrowserCreated(Sender: TObject);
|
||||
procedure GoBtnRightClick(Sender: TObject);
|
||||
procedure CloseBtnRightClick(Sender: TObject);
|
||||
procedure RightBrowserClosed(Sender: TObject);
|
||||
|
||||
procedure DoShowModal(Data: PtrInt);
|
||||
procedure MaybeTerminateApp(Sender: TObject);
|
||||
procedure MaybeCloseApp(Sender: TObject);
|
||||
protected
|
||||
FBrowserLeft, FBrowserRight: TLazarusBrowserWindow;
|
||||
FClosingBrowsers: TList;
|
||||
|
||||
{$IFDEF WINDOWS}
|
||||
procedure WMEnterMenuLoop(var aMessage: TMessage); message WM_ENTERMENULOOP;
|
||||
procedure WMExitMenuLoop(var aMessage: TMessage); message WM_EXITMENULOOP;
|
||||
{$ENDIF}
|
||||
|
||||
public
|
||||
constructor Create(TheOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
|
||||
end;
|
||||
|
||||
var
|
||||
Form1: TForm1;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
// This is a demo with the simplest web browser you can build using CEF4Delphi and
|
||||
// it doesn't show any sign of progress like other web browsers do.
|
||||
|
||||
// Remember that it may take a few seconds to load if Windows update, your antivirus or
|
||||
// any other windows service is using your hard drive.
|
||||
|
||||
// Depending on your internet connection it may take longer than expected.
|
||||
|
||||
// Please check that your firewall or antivirus are not blocking this application
|
||||
// or the domain "google.com". If you don't live in the US, you'll be redirected to
|
||||
// another domain which will take a little time too.
|
||||
|
||||
// This demo uses a TChromium and a TCEFLinkedWindowParent
|
||||
|
||||
// We need to use TCEFLinkedWindowParent in Linux to update the browser
|
||||
// visibility and size automatically.
|
||||
|
||||
// Destruction steps
|
||||
// =================
|
||||
// 1. FormCloseQuery sets CanClose to FALSE calls TChromium.CloseBrowser which triggers the TChromium.OnClose event.
|
||||
// 2. TChromium.OnClose sets aAction to cbaClose to destroy the browser, which triggers the TChromium.OnBeforeClose event.
|
||||
// 3. TChromium.OnBeforeClose sets FCanClose := True and sends CEF_BEFORECLOSE to close the form.
|
||||
|
||||
uses
|
||||
uCEFApplication;
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
procedure TForm1.OpenBtnLeftClick(Sender: TObject);
|
||||
begin
|
||||
FBrowserLeft := TLazarusBrowserWindow.Create(Self);
|
||||
FBrowserLeft.Chromium.OnBeforePopup := @Chromium1BeforePopup;
|
||||
FBrowserLeft.Chromium.OnOpenUrlFromTab := @Chromium1OpenUrlFromTab;
|
||||
FBrowserLeft.OnBrowserCreated := @LeftBrowserCreated;
|
||||
FBrowserLeft.OnBrowserClosed := @LeftBrowserClosed;
|
||||
FBrowserLeft.Align := alClient;
|
||||
FBrowserLeft.Parent := PanelLeft;
|
||||
|
||||
OpenBtnLeft.Enabled := False;
|
||||
GoBtnLeftClick(nil);
|
||||
end;
|
||||
|
||||
procedure TForm1.LeftBrowserCreated(Sender: TObject);
|
||||
begin
|
||||
AddressPnlLeft.Enabled := True;
|
||||
end;
|
||||
|
||||
procedure TForm1.GoBtnLeftClick(Sender: TObject);
|
||||
begin
|
||||
FBrowserLeft.LoadURL(UTF8Decode(AddressEdtLeft.Text));
|
||||
end;
|
||||
|
||||
procedure TForm1.CloseBtnLeftClick(Sender: TObject);
|
||||
begin
|
||||
AddressPnlLeft.Enabled := False;
|
||||
FClosingBrowsers.Add(FBrowserLeft);
|
||||
FBrowserLeft.CloseBrowser(True);
|
||||
FBrowserLeft := nil;
|
||||
//FreeAndNil(FBrowserLeft);
|
||||
OpenBtnLeft.Enabled := True;
|
||||
end;
|
||||
|
||||
procedure TForm1.LeftBrowserClosed(Sender: TObject);
|
||||
begin
|
||||
FClosingBrowsers.Remove(Sender);
|
||||
Sender.Free;
|
||||
end;
|
||||
|
||||
|
||||
procedure TForm1.OpenBtnRightClick(Sender: TObject);
|
||||
begin
|
||||
FBrowserRight := TLazarusBrowserWindow.Create(Self);
|
||||
FBrowserRight.Chromium.OnBeforePopup := @Chromium1BeforePopup;
|
||||
FBrowserRight.Chromium.OnOpenUrlFromTab := @Chromium1OpenUrlFromTab;
|
||||
FBrowserRight.OnBrowserCreated := @RightBrowserCreated;
|
||||
{$IFDEF MACOSX}
|
||||
FBrowserRight.OnBrowserClosed := @RightBrowserClosed;
|
||||
{$ENDIF}
|
||||
FBrowserRight.Align := alClient;
|
||||
FBrowserRight.Parent := PanelRight;
|
||||
|
||||
OpenBtnRight.Enabled := False;
|
||||
GoBtnRightClick(nil);
|
||||
end;
|
||||
|
||||
procedure TForm1.RightBrowserCreated(Sender: TObject);
|
||||
begin
|
||||
AddressPnlRight.Enabled := True;
|
||||
end;
|
||||
|
||||
procedure TForm1.GoBtnRightClick(Sender: TObject);
|
||||
begin
|
||||
FBrowserRight.LoadURL(UTF8Decode(AddressEdtRight.Text));
|
||||
end;
|
||||
|
||||
procedure TForm1.CloseBtnRightClick(Sender: TObject);
|
||||
begin
|
||||
AddressPnlRight.Enabled := False;
|
||||
{$IFDEF MACOSX}
|
||||
FClosingBrowsers.Add(FBrowserRight);
|
||||
FBrowserRight.CloseBrowser(True);
|
||||
FBrowserRight := nil;
|
||||
{$ELSE}
|
||||
FreeAndNil(FBrowserRight);
|
||||
{$ENDIF}
|
||||
OpenBtnRight.Enabled := True;
|
||||
end;
|
||||
|
||||
procedure TForm1.RightBrowserClosed(Sender: TObject);
|
||||
begin
|
||||
FClosingBrowsers.Remove(Sender);
|
||||
Sender.Free;
|
||||
end;
|
||||
|
||||
{$IFDEF WINDOWS}
|
||||
procedure TForm1.WMEnterMenuLoop(var aMessage: TMessage);
|
||||
begin
|
||||
inherited;
|
||||
|
||||
if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := True;
|
||||
end;
|
||||
|
||||
procedure TForm1.WMExitMenuLoop(var aMessage: TMessage);
|
||||
begin
|
||||
inherited;
|
||||
|
||||
if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := False;
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
constructor TForm1.Create(TheOwner: TComponent);
|
||||
begin
|
||||
FClosingBrowsers := TList.Create;
|
||||
inherited Create(TheOwner);
|
||||
end;
|
||||
|
||||
destructor TForm1.Destroy;
|
||||
begin
|
||||
inherited Destroy;
|
||||
FreeAndNil(FClosingBrowsers);
|
||||
end;
|
||||
|
||||
procedure TForm1.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: Boolean; var Result: Boolean);
|
||||
begin
|
||||
// For simplicity, this demo blocks all popup windows and new tabs
|
||||
Result := (targetDisposition in [WOD_NEW_FOREGROUND_TAB, WOD_NEW_BACKGROUND_TAB, WOD_NEW_POPUP, WOD_NEW_WINDOW]);
|
||||
end;
|
||||
|
||||
procedure TForm1.MaybeTerminateApp(Sender: TObject);
|
||||
begin
|
||||
Sender.Free;
|
||||
FClosingBrowsers.Remove(Sender);
|
||||
if FClosingBrowsers.Count = 0 then
|
||||
Application.Terminate;
|
||||
end;
|
||||
|
||||
procedure TForm1.BtnCloseAppClick(Sender: TObject);
|
||||
begin
|
||||
// Does not call CloseQuery
|
||||
Hide;
|
||||
{$IFDEF MACOSX}
|
||||
(* This demo takes no precaution against the App being closed by outher means
|
||||
while waiting for all browsers to close
|
||||
*)
|
||||
if FBrowserLeft <> nil then begin
|
||||
FBrowserLeft.OnBrowserClosed := @MaybeTerminateApp;
|
||||
CloseBtnLeftClick(nil);
|
||||
end;
|
||||
if FBrowserRight <> nil then begin
|
||||
FBrowserRight.OnBrowserClosed := @MaybeTerminateApp;
|
||||
CloseBtnRightClick(nil);
|
||||
end;
|
||||
if FClosingBrowsers.Count = 0 then
|
||||
Application.Terminate;
|
||||
{$ELSE}
|
||||
if FBrowserLeft <> nil then
|
||||
FBrowserLeft.WaitForBrowserClosed;
|
||||
if FBrowserRight <> nil then
|
||||
FBrowserRight.WaitForBrowserClosed;
|
||||
Application.Terminate;
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
procedure TForm1.BtnCloseFormClick(Sender: TObject);
|
||||
begin
|
||||
Close;
|
||||
end;
|
||||
|
||||
procedure TForm1.BtnModalClick(Sender: TObject);
|
||||
begin
|
||||
{$IFDEF MACOSX}
|
||||
Application.QueueAsyncCall(@DoShowModal, 0);
|
||||
{$ELSE}
|
||||
DoShowModal(0);
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
procedure TForm1.DoShowModal(Data: PtrInt);
|
||||
var
|
||||
m: TForm1;
|
||||
begin
|
||||
m := TForm1.Create(Application);
|
||||
m.BtnModal.Enabled := False;
|
||||
m.Caption := 'MOD';
|
||||
m.BtnCloseApp.Visible := False;
|
||||
m.ShowModal;
|
||||
m.Free;
|
||||
end;
|
||||
|
||||
procedure TForm1.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 TForm1.MaybeCloseApp(Sender: TObject);
|
||||
begin
|
||||
Sender.Free;
|
||||
FClosingBrowsers.Remove(Sender);
|
||||
if FClosingBrowsers.Count = 0 then
|
||||
Close;
|
||||
end;
|
||||
|
||||
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
||||
begin
|
||||
Hide;
|
||||
if FBrowserLeft <> nil then begin
|
||||
FBrowserLeft.OnBrowserClosed := @MaybeCloseApp;
|
||||
CloseBtnLeftClick(nil);
|
||||
end;
|
||||
if FBrowserRight <> nil then begin
|
||||
FBrowserRight.OnBrowserClosed := @MaybeCloseApp;
|
||||
CloseBtnRightClick(nil);
|
||||
end;
|
||||
CanClose := FClosingBrowsers.Count = 0;
|
||||
end;
|
||||
|
||||
procedure TForm1.FormCreate(Sender: TObject);
|
||||
begin
|
||||
OpenBtnLeftClick(nil);
|
||||
end;
|
||||
|
||||
initialization
|
||||
{$IFDEF DARWIN} // $IFDEF MACOSX
|
||||
AddCrDelegate;
|
||||
{$ENDIF}
|
||||
if GlobalCEFApp = nil then begin
|
||||
CreateGlobalCEFApp;
|
||||
if not GlobalCEFApp.StartMainProcess then begin
|
||||
DestroyGlobalCEFApp;
|
||||
DestroyGlobalCEFWorkScheduler;
|
||||
halt(0); // exit the subprocess
|
||||
end;
|
||||
end;
|
||||
|
||||
finalization
|
||||
(* Destroy from this unit, which is used after "Interfaces". So this happens before the Application object is destroyed *)
|
||||
if GlobalCEFWorkScheduler <> nil then
|
||||
GlobalCEFWorkScheduler.StopScheduler;
|
||||
DestroyGlobalCEFApp;
|
||||
DestroyGlobalCEFWorkScheduler;
|
||||
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user