You've already forked CEF4Delphi
mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2025-08-04 21:32:54 +02:00
Added ConsoleBrowser2 and WebpageSnapshot demos
- Split the Lazarus demos directory into "Lazarus_Windows" and "Lazarus_Linux". - Added OSRExternalPumpBrowser and TinyBrowser2 demos to "Lazarus_Linux". - Set TBufferPanel.GetScreenScale as virtual. - Added DevTools to the SchemeRegistrationBrowser demo. - Modified the SchemeRegistrationBrowser demo to receive XMLHttpRequest requests from JavaScript.
This commit is contained in:
2
demos/Lazarus_Windows/JavaScript/JSEval/00-Delete.bat
Normal file
2
demos/Lazarus_Windows/JavaScript/JSEval/00-Delete.bat
Normal file
@ -0,0 +1,2 @@
|
||||
rmdir /S /Q lib
|
||||
rmdir /S /Q backup
|
98
demos/Lazarus_Windows/JavaScript/JSEval/JSEval.lpi
Normal file
98
demos/Lazarus_Windows/JavaScript/JSEval/JSEval.lpi
Normal file
@ -0,0 +1,98 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<MainUnitHasUsesSectionForAllUnits Value="False"/>
|
||||
<MainUnitHasCreateFormStatements Value="False"/>
|
||||
<MainUnitHasTitleStatement Value="False"/>
|
||||
<MainUnitHasScaledStatement Value="False"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<Title Value="JSEval"/>
|
||||
<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="3">
|
||||
<Unit0>
|
||||
<Filename Value="JSEval.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="uJSEval.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="JSEvalFrm"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
</Unit1>
|
||||
<Unit2>
|
||||
<Filename Value="uSimpleTextViewer.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="SimpleTextViewerFrm"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
</Unit2>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<Target>
|
||||
<Filename Value="..\..\..\..\bin\JSEval"/>
|
||||
</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>
|
73
demos/Lazarus_Windows/JavaScript/JSEval/JSEval.lpr
Normal file
73
demos/Lazarus_Windows/JavaScript/JSEval/JSEval.lpr
Normal file
@ -0,0 +1,73 @@
|
||||
// ************************************************************************
|
||||
// ***************************** 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 JSEval;
|
||||
|
||||
{$MODE Delphi}
|
||||
|
||||
{$I cef.inc}
|
||||
|
||||
uses
|
||||
Forms, Windows,
|
||||
LCLIntf, LCLType, LMessages, Interfaces,
|
||||
uCEFApplication,
|
||||
uJSEval in 'uJSEval.pas' {JSEvalFrm},
|
||||
uSimpleTextViewer in 'uSimpleTextViewer.pas' {SimpleTextViewerFrm};
|
||||
|
||||
{.$R *.res}
|
||||
|
||||
// CEF3 needs to set the LARGEADDRESSAWARE flag which allows 32-bit processes to use up to 3GB of RAM.
|
||||
{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE}
|
||||
|
||||
begin
|
||||
// GlobalCEFApp creation and initialization moved to a different unit to fix the memory leak described in the bug #89
|
||||
// https://github.com/salvadordf/CEF4Delphi/issues/89
|
||||
CreateGlobalCEFApp;
|
||||
|
||||
if GlobalCEFApp.StartMainProcess then
|
||||
begin
|
||||
Application.Initialize;
|
||||
{$IFDEF DELPHI11_UP}
|
||||
Application.MainFormOnTaskbar := True;
|
||||
{$ENDIF}
|
||||
Application.CreateForm(TJSEvalFrm, JSEvalFrm);
|
||||
Application.CreateForm(TSimpleTextViewerFrm, SimpleTextViewerFrm);
|
||||
Application.Run;
|
||||
end;
|
||||
|
||||
DestroyGlobalCEFApp;
|
||||
end.
|
241
demos/Lazarus_Windows/JavaScript/JSEval/JSEval.lps
Normal file
241
demos/Lazarus_Windows/JavaScript/JSEval/JSEval.lps
Normal file
@ -0,0 +1,241 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectSession>
|
||||
<PathDelim Value="\"/>
|
||||
<Version Value="11"/>
|
||||
<BuildModes Active="Default"/>
|
||||
<Units Count="14">
|
||||
<Unit0>
|
||||
<Filename Value="JSEval.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<EditorIndex Value="1"/>
|
||||
<TopLine Value="41"/>
|
||||
<CursorPos X="76" Y="60"/>
|
||||
<UsageCount Value="21"/>
|
||||
<Loaded Value="True"/>
|
||||
<DefaultSyntaxHighlighter Value="Delphi"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="uJSEval.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="JSEvalFrm"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<TopLine Value="169"/>
|
||||
<CursorPos X="31" Y="181"/>
|
||||
<UsageCount Value="21"/>
|
||||
<Bookmarks Count="1">
|
||||
<Item0 X="85" Y="485" ID="1"/>
|
||||
</Bookmarks>
|
||||
<Loaded Value="True"/>
|
||||
<LoadedDesigner Value="True"/>
|
||||
<DefaultSyntaxHighlighter Value="Delphi"/>
|
||||
</Unit1>
|
||||
<Unit2>
|
||||
<Filename Value="uSimpleTextViewer.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="SimpleTextViewerFrm"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<UsageCount Value="21"/>
|
||||
<DefaultSyntaxHighlighter Value="Delphi"/>
|
||||
</Unit2>
|
||||
<Unit3>
|
||||
<Filename Value="..\..\..\..\..\..\fpcsrc\packages\fcl-base\src\base64.pp"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="34"/>
|
||||
<CursorPos X="28" Y="89"/>
|
||||
<UsageCount Value="10"/>
|
||||
<DefaultSyntaxHighlighter Value="Delphi"/>
|
||||
</Unit3>
|
||||
<Unit4>
|
||||
<Filename Value="C:\lazarus\fpc\3.0.4\source\packages\fcl-base\src\base64.pp"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="25"/>
|
||||
<CursorPos X="3" Y="33"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit4>
|
||||
<Unit5>
|
||||
<Filename Value="C:\lazarus\fpc\3.0.4\source\rtl\objpas\classes\classesh.inc"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="968"/>
|
||||
<CursorPos X="14" Y="990"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit5>
|
||||
<Unit6>
|
||||
<Filename Value="C:\lazarus\fpc\3.0.4\source\rtl\objpas\classes\streams.inc"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="746"/>
|
||||
<CursorPos X="3" Y="751"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit6>
|
||||
<Unit7>
|
||||
<Filename Value="..\..\..\..\source\uCEFBinaryValue.pas"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="120"/>
|
||||
<CursorPos Y="132"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit7>
|
||||
<Unit8>
|
||||
<Filename Value="..\..\..\..\source\uCEFCookieAccessFilter.pas"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="199"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit8>
|
||||
<Unit9>
|
||||
<Filename Value="..\..\..\..\source\uCEFResourceReadCallback.pas"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="33"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit9>
|
||||
<Unit10>
|
||||
<Filename Value="..\..\..\..\source\uCEFResourceRequestHandler.pas"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="607"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit10>
|
||||
<Unit11>
|
||||
<Filename Value="..\..\..\..\source\uCEFResourceSkipCallback.pas"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="33"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit11>
|
||||
<Unit12>
|
||||
<Filename Value="..\..\..\..\source\uCEFResourceHandler.pas"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="331"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit12>
|
||||
<Unit13>
|
||||
<Filename Value="..\..\..\..\source\uCEFRequestHandler.pas"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="571"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit13>
|
||||
</Units>
|
||||
<JumpHistory Count="29" HistoryIndex="28">
|
||||
<Position1>
|
||||
<Filename Value="uJSEval.pas"/>
|
||||
<Caret Line="373" Column="76" TopLine="336"/>
|
||||
</Position1>
|
||||
<Position2>
|
||||
<Filename Value="uJSEval.pas"/>
|
||||
<Caret Line="470" Column="70" TopLine="433"/>
|
||||
</Position2>
|
||||
<Position3>
|
||||
<Filename Value="uJSEval.pas"/>
|
||||
<Caret Line="524" Column="40" TopLine="487"/>
|
||||
</Position3>
|
||||
<Position4>
|
||||
<Filename Value="uJSEval.pas"/>
|
||||
<Caret Line="555" Column="39" TopLine="518"/>
|
||||
</Position4>
|
||||
<Position5>
|
||||
<Filename Value="uJSEval.pas"/>
|
||||
<Caret Line="63" Column="18" TopLine="41"/>
|
||||
</Position5>
|
||||
<Position6>
|
||||
<Filename Value="uJSEval.pas"/>
|
||||
<Caret Line="373" Column="76" TopLine="336"/>
|
||||
</Position6>
|
||||
<Position7>
|
||||
<Filename Value="JSEval.lpr"/>
|
||||
<Caret Line="60" Column="76" TopLine="44"/>
|
||||
</Position7>
|
||||
<Position8>
|
||||
<Filename Value="uJSEval.pas"/>
|
||||
<Caret Line="125" Column="29" TopLine="114"/>
|
||||
</Position8>
|
||||
<Position9>
|
||||
<Filename Value="uJSEval.pas"/>
|
||||
<Caret Line="536" Column="38" TopLine="518"/>
|
||||
</Position9>
|
||||
<Position10>
|
||||
<Filename Value="uJSEval.pas"/>
|
||||
<Caret Line="511" Column="75" TopLine="499"/>
|
||||
</Position10>
|
||||
<Position11>
|
||||
<Filename Value="uJSEval.pas"/>
|
||||
<Caret Line="463" Column="50" TopLine="452"/>
|
||||
</Position11>
|
||||
<Position12>
|
||||
<Filename Value="uJSEval.pas"/>
|
||||
<Caret Line="372" TopLine="360"/>
|
||||
</Position12>
|
||||
<Position13>
|
||||
<Filename Value="uJSEval.pas"/>
|
||||
<Caret Line="54" Column="73" TopLine="24"/>
|
||||
</Position13>
|
||||
<Position14>
|
||||
<Filename Value="uJSEval.pas"/>
|
||||
<Caret Line="51" Column="90" TopLine="24"/>
|
||||
</Position14>
|
||||
<Position15>
|
||||
<Filename Value="uJSEval.pas"/>
|
||||
<Caret Line="59" Column="37" TopLine="24"/>
|
||||
</Position15>
|
||||
<Position16>
|
||||
<Filename Value="uJSEval.pas"/>
|
||||
<Caret Line="181" Column="63" TopLine="162"/>
|
||||
</Position16>
|
||||
<Position17>
|
||||
<Filename Value="JSEval.lpr"/>
|
||||
<Caret Line="60" Column="76" TopLine="41"/>
|
||||
</Position17>
|
||||
<Position18>
|
||||
<Filename Value="uJSEval.pas"/>
|
||||
<Caret Line="125" Column="11" TopLine="121"/>
|
||||
</Position18>
|
||||
<Position19>
|
||||
<Filename Value="uJSEval.pas"/>
|
||||
<Caret Line="542" Column="86" TopLine="533"/>
|
||||
</Position19>
|
||||
<Position20>
|
||||
<Filename Value="uJSEval.pas"/>
|
||||
<Caret Line="94" Column="43" TopLine="77"/>
|
||||
</Position20>
|
||||
<Position21>
|
||||
<Filename Value="uJSEval.pas"/>
|
||||
<Caret Line="210" Column="39" TopLine="203"/>
|
||||
</Position21>
|
||||
<Position22>
|
||||
<Filename Value="uJSEval.pas"/>
|
||||
<Caret Line="86" Column="71" TopLine="76"/>
|
||||
</Position22>
|
||||
<Position23>
|
||||
<Filename Value="uJSEval.pas"/>
|
||||
<Caret Line="510" Column="62" TopLine="492"/>
|
||||
</Position23>
|
||||
<Position24>
|
||||
<Filename Value="JSEval.lpr"/>
|
||||
<Caret Line="60" Column="76" TopLine="41"/>
|
||||
</Position24>
|
||||
<Position25>
|
||||
<Filename Value="uJSEval.pas"/>
|
||||
<Caret Line="126" Column="11" TopLine="109"/>
|
||||
</Position25>
|
||||
<Position26>
|
||||
<Filename Value="uJSEval.pas"/>
|
||||
<Caret Line="542" TopLine="538"/>
|
||||
</Position26>
|
||||
<Position27>
|
||||
<Filename Value="uJSEval.pas"/>
|
||||
<Caret Line="552" TopLine="548"/>
|
||||
</Position27>
|
||||
<Position28>
|
||||
<Filename Value="uJSEval.pas"/>
|
||||
<Caret Line="183" Column="82" TopLine="169"/>
|
||||
</Position28>
|
||||
<Position29>
|
||||
<Filename Value="uJSEval.pas"/>
|
||||
<Caret Line="182" Column="82" TopLine="168"/>
|
||||
</Position29>
|
||||
</JumpHistory>
|
||||
<RunParams>
|
||||
<FormatVersion Value="2"/>
|
||||
<Modes Count="0" ActiveMode=""/>
|
||||
</RunParams>
|
||||
</ProjectSession>
|
||||
</CONFIG>
|
456
demos/Lazarus_Windows/JavaScript/JSEval/cef.inc
Normal file
456
demos/Lazarus_Windows/JavaScript/JSEval/cef.inc
Normal file
@ -0,0 +1,456 @@
|
||||
// ************************************************************************
|
||||
// ***************************** 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}
|
||||
|
76
demos/Lazarus_Windows/JavaScript/JSEval/uJSEval.lfm
Normal file
76
demos/Lazarus_Windows/JavaScript/JSEval/uJSEval.lfm
Normal file
@ -0,0 +1,76 @@
|
||||
object JSEvalFrm: TJSEvalFrm
|
||||
Left = 147
|
||||
Height = 571
|
||||
Top = 117
|
||||
Width = 878
|
||||
Caption = 'JSEval'
|
||||
ClientHeight = 571
|
||||
ClientWidth = 878
|
||||
Color = clBtnFace
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'Tahoma'
|
||||
OnCloseQuery = FormCloseQuery
|
||||
OnShow = FormShow
|
||||
Position = poScreenCenter
|
||||
LCLVersion = '2.0.6.0'
|
||||
object CEFWindowParent1: TCEFWindowParent
|
||||
Left = 0
|
||||
Height = 550
|
||||
Top = 21
|
||||
Width = 878
|
||||
Align = alClient
|
||||
TabOrder = 0
|
||||
end
|
||||
object AddressBarPnl: TPanel
|
||||
Left = 0
|
||||
Height = 21
|
||||
Top = 0
|
||||
Width = 878
|
||||
Align = alTop
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 21
|
||||
ClientWidth = 878
|
||||
DoubleBuffered = True
|
||||
Enabled = False
|
||||
ParentDoubleBuffered = False
|
||||
TabOrder = 1
|
||||
object GoBtn: TButton
|
||||
Left = 847
|
||||
Height = 21
|
||||
Top = 0
|
||||
Width = 31
|
||||
Align = alRight
|
||||
Caption = 'Go'
|
||||
OnClick = GoBtnClick
|
||||
TabOrder = 0
|
||||
end
|
||||
object AddressEdt: TEdit
|
||||
Left = 0
|
||||
Height = 21
|
||||
Top = 0
|
||||
Width = 847
|
||||
Align = alClient
|
||||
TabOrder = 1
|
||||
Text = 'https://www.google.com'
|
||||
end
|
||||
end
|
||||
object Chromium1: TChromium
|
||||
OnProcessMessageReceived = Chromium1ProcessMessageReceived
|
||||
OnBeforeContextMenu = Chromium1BeforeContextMenu
|
||||
OnContextMenuCommand = Chromium1ContextMenuCommand
|
||||
OnBeforePopup = Chromium1BeforePopup
|
||||
OnAfterCreated = Chromium1AfterCreated
|
||||
OnBeforeClose = Chromium1BeforeClose
|
||||
OnClose = Chromium1Close
|
||||
left = 16
|
||||
top = 40
|
||||
end
|
||||
object Timer1: TTimer
|
||||
Enabled = False
|
||||
Interval = 300
|
||||
OnTimer = Timer1Timer
|
||||
left = 16
|
||||
top = 96
|
||||
end
|
||||
end
|
578
demos/Lazarus_Windows/JavaScript/JSEval/uJSEval.pas
Normal file
578
demos/Lazarus_Windows/JavaScript/JSEval/uJSEval.pas
Normal file
@ -0,0 +1,578 @@
|
||||
// ************************************************************************
|
||||
// ***************************** 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 uJSEval;
|
||||
|
||||
{$MODE Delphi}
|
||||
|
||||
{$I cef.inc}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
LCLIntf, LCLType, LMessages, Messages, SysUtils, Variants, Classes, Graphics, Menus,
|
||||
Controls, Forms, Dialogs, StdCtrls, ExtCtrls, Types, ComCtrls, ClipBrd, base64,
|
||||
uCEFChromium, uCEFWindowParent, uCEFInterfaces, uCEFApplication, uCEFTypes, uCEFConstants,
|
||||
uCEFWinControl, uCEFSentinel;
|
||||
|
||||
const
|
||||
MINIBROWSER_SHOWTEXTVIEWER = WM_APP + $101;
|
||||
MINIBROWSER_EVALJSCODE = WM_APP + $102;
|
||||
MINIBROWSER_JSBINPARAM = WM_APP + $103;
|
||||
MINIBROWSER_GETSCROLLPOS = WM_APP + $104;
|
||||
|
||||
MINIBROWSER_CONTEXTMENU_EVALJSCODE = MENU_ID_USER_FIRST + 1;
|
||||
MINIBROWSER_CONTEXTMENU_JSBINPARAM = MENU_ID_USER_FIRST + 2;
|
||||
MINIBROWSER_CONTEXTMENU_GETSCROLLPOS = MENU_ID_USER_FIRST + 3;
|
||||
|
||||
EVAL_JS = 'JSContextEvalDemo';
|
||||
BINARY_PARAM_JS = 'JSBinaryParameter';
|
||||
|
||||
type
|
||||
|
||||
{ TJSEvalFrm }
|
||||
|
||||
TJSEvalFrm = class(TForm)
|
||||
CEFWindowParent1: TCEFWindowParent;
|
||||
Chromium1: TChromium;
|
||||
AddressBarPnl: TPanel;
|
||||
GoBtn: TButton;
|
||||
AddressEdt: TEdit;
|
||||
Timer1: TTimer;
|
||||
procedure CEFSentinel1Close(Sender: TObject);
|
||||
procedure Chromium1AfterCreated(Sender: TObject; const browser: ICefBrowser);
|
||||
procedure GoBtnClick(Sender: TObject);
|
||||
procedure FormShow(Sender: TObject);
|
||||
|
||||
procedure Chromium1ProcessMessageReceived(Sender: TObject;
|
||||
const browser: ICefBrowser; const frame: ICefFrame; sourceProcess: TCefProcessId;
|
||||
const message: ICefProcessMessage; out Result: Boolean);
|
||||
procedure Chromium1BeforeContextMenu(Sender: TObject;
|
||||
const browser: ICefBrowser; const frame: ICefFrame;
|
||||
const params: ICefContextMenuParams; const model: ICefMenuModel);
|
||||
procedure Chromium1ContextMenuCommand(Sender: TObject;
|
||||
const browser: ICefBrowser; const frame: ICefFrame;
|
||||
const params: ICefContextMenuParams; commandId: Integer;
|
||||
eventFlags: Cardinal; out Result: Boolean);
|
||||
procedure Timer1Timer(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 FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
||||
procedure Chromium1Close(Sender: TObject; const browser: ICefBrowser;
|
||||
var aAction : TCefCloseBrowserAction);
|
||||
procedure Chromium1BeforeClose(Sender: TObject;
|
||||
const browser: ICefBrowser);
|
||||
|
||||
private
|
||||
{ Private declarations }
|
||||
|
||||
protected
|
||||
FText : string;
|
||||
// Variables to control when can we destroy the form safely
|
||||
FCanClose : boolean; // Set to True in TChromium.OnBeforeClose
|
||||
FClosing : boolean; // Set to True in the CloseQuery event.
|
||||
|
||||
procedure BrowserCreatedMsg(var aMessage : TMessage); message CEF_AFTERCREATED;
|
||||
procedure BrowserDestroyMsg(var aMessage : TMessage); message CEF_DESTROY;
|
||||
procedure ShowTextViewerMsg(var aMessage : TMessage); message MINIBROWSER_SHOWTEXTVIEWER;
|
||||
procedure EvalJSCodeMsg(var aMessage : TMessage); message MINIBROWSER_EVALJSCODE;
|
||||
procedure GetScrollPosMsg(var aMessage : TMessage); message MINIBROWSER_GETSCROLLPOS;
|
||||
procedure EvalJSBinParamMsg(var aMessage : TMessage); message MINIBROWSER_JSBINPARAM;
|
||||
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;
|
||||
end;
|
||||
|
||||
var
|
||||
JSEvalFrm: TJSEvalFrm;
|
||||
|
||||
procedure CreateGlobalCEFApp;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
uses
|
||||
uSimpleTextViewer, uCEFProcessMessage, uCEFBinaryValue, uCEFMiscFunctions;
|
||||
|
||||
// 99.9% of the code in this demo was created by xpert13 and shared in the CEF4Delphi forum.
|
||||
|
||||
// Steps to evaluate some JavaScript code using the V8Context
|
||||
// ----------------------------------------------------------
|
||||
// 1. Set GlobalCEFApp.OnProcessMessageReceived to RenderProcessHandler_OnProcessMessageReceivedEvent.
|
||||
// 2. To get the Javascript code in this demo we use a context menu that sends a MINIBROWSER_EVALJSCODE to the form.
|
||||
// 3. The EvalJSCodeMsg asks for the Javascript code and sends it to the renderer using a process message.
|
||||
// 4. RenderProcessHandler_OnProcessMessageReceivedEvent receives the process message and calls ParseEvalJsAnswer
|
||||
// to evaluate the code.
|
||||
// 5. ParseEvalJsAnswer evaluates the code and sends a message with the results to the browser process using a
|
||||
// process message.
|
||||
// 6. Chromium1ProcessMessageReceived receives the message, stores the results and sends a
|
||||
// MINIBROWSER_SHOWTEXTVIEWER message to the form.
|
||||
// 7. ShowTextViewerMsg shows the results safely using a SimpleTextViewer.
|
||||
|
||||
|
||||
// This demo also has an example of binary parameters in process messages
|
||||
// ----------------------------------------------------------------------
|
||||
// 1. Set GlobalCEFApp.OnProcessMessageReceived to RenderProcessHandler_OnProcessMessageReceivedEvent.
|
||||
// 2. The context menu has a 'Send JPEG image' option that sends a MINIBROWSER_JSBINPARAM message to the form.
|
||||
// 3. EvalJSBinParamMsg asks for a JPEG image and sends a process message with a ICefBinaryValue parameter to the
|
||||
// renderer process.
|
||||
// 4. The renderer process parses the binary parameter in the ParseBinaryValue function and sends back the image
|
||||
// size and encoded image data to the browser process.
|
||||
// 5. Chromium1ProcessMessageReceived receives the message, stores the results and sends a
|
||||
// MINIBROWSER_SHOWTEXTVIEWER message to the form.
|
||||
// 6. ShowTextViewerMsg shows the results safely using a SimpleTextViewer.
|
||||
|
||||
|
||||
// About binary parameters
|
||||
// -----------------------
|
||||
// There is a size limit in the binary parameters of only a few kilobytes.
|
||||
// For more info and alternatives read this thread in the official CEF forum :
|
||||
// http://www.magpcss.org/ceforum/viewtopic.php?f=6&t=10590
|
||||
//
|
||||
// Compress the binary data if necessary!
|
||||
|
||||
|
||||
// Destruction steps
|
||||
// =================
|
||||
// 1. FormCloseQuery sets CanClose to FALSE calls TChromium.CloseBrowser which triggers the TChromium.OnClose event.
|
||||
// 2. TChromium.OnClose sends a CEFBROWSER_DESTROY message to destroy CEFWindowParent1 in the main thread, which triggers the TChromium.OnBeforeClose event.
|
||||
// 3. TChromium.OnBeforeClose sets FCanClose := True and sends WM_CLOSE to the form.
|
||||
|
||||
procedure TJSEvalFrm.Chromium1AfterCreated(Sender: TObject; const browser: ICefBrowser);
|
||||
begin
|
||||
PostMessage(Handle, CEF_AFTERCREATED, 0, 0);
|
||||
end;
|
||||
|
||||
procedure TJSEvalFrm.CEFSentinel1Close(Sender: TObject);
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
procedure TJSEvalFrm.Chromium1BeforeClose(Sender: TObject;
|
||||
const browser: ICefBrowser);
|
||||
begin
|
||||
FCanClose := True;
|
||||
PostMessage(Handle, WM_CLOSE, 0, 0);
|
||||
end;
|
||||
|
||||
procedure TJSEvalFrm.Chromium1BeforeContextMenu(Sender : TObject;
|
||||
const browser : ICefBrowser;
|
||||
const frame : ICefFrame;
|
||||
const params : ICefContextMenuParams;
|
||||
const model : ICefMenuModel);
|
||||
begin
|
||||
model.AddItem(MINIBROWSER_CONTEXTMENU_EVALJSCODE, 'Evaluate JavaScript code...');
|
||||
model.AddItem(MINIBROWSER_CONTEXTMENU_GETSCROLLPOS, 'Get vertical scroll position...');
|
||||
// TODO: Fix bug in creating a TCefBinaryValueRef
|
||||
model.AddItem(MINIBROWSER_CONTEXTMENU_JSBINPARAM, 'Send JPEG image...');
|
||||
end;
|
||||
|
||||
procedure TJSEvalFrm.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 TJSEvalFrm.Chromium1Close(Sender: TObject;
|
||||
const browser: ICefBrowser; var aAction : TCefCloseBrowserAction);
|
||||
begin
|
||||
PostMessage(Handle, CEF_DESTROY, 0, 0);
|
||||
aAction := cbaDelay;
|
||||
end;
|
||||
|
||||
procedure TJSEvalFrm.Chromium1ContextMenuCommand(Sender : TObject;
|
||||
const browser : ICefBrowser;
|
||||
const frame : ICefFrame;
|
||||
const params : ICefContextMenuParams;
|
||||
commandId : Integer;
|
||||
eventFlags : Cardinal;
|
||||
out Result : Boolean);
|
||||
begin
|
||||
Result := False;
|
||||
|
||||
case commandId of
|
||||
MINIBROWSER_CONTEXTMENU_EVALJSCODE : PostMessage(Handle, MINIBROWSER_EVALJSCODE, 0, 0);
|
||||
MINIBROWSER_CONTEXTMENU_JSBINPARAM : PostMessage(Handle, MINIBROWSER_JSBINPARAM, 0, 0);
|
||||
MINIBROWSER_CONTEXTMENU_GETSCROLLPOS : PostMessage(Handle, MINIBROWSER_GETSCROLLPOS, 0, 0);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TJSEvalFrm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
||||
begin
|
||||
CanClose := FCanClose;
|
||||
|
||||
if not(FClosing) then
|
||||
begin
|
||||
FClosing := True;
|
||||
Visible := False;
|
||||
Chromium1.CloseBrowser(True);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TJSEvalFrm.FormShow(Sender: TObject);
|
||||
begin
|
||||
// GlobalCEFApp.GlobalContextInitialized has to be TRUE before creating any browser
|
||||
// If it's not initialized yet, we use a simple timer to create the browser later.
|
||||
if not(Chromium1.CreateBrowser(CEFWindowParent1, '')) then Timer1.Enabled := True;
|
||||
end;
|
||||
|
||||
procedure TJSEvalFrm.GoBtnClick(Sender: TObject);
|
||||
begin
|
||||
Chromium1.LoadURL(AddressEdt.Text);
|
||||
end;
|
||||
|
||||
procedure TJSEvalFrm.BrowserCreatedMsg(var aMessage : TMessage);
|
||||
begin
|
||||
CEFWindowParent1.UpdateSize;
|
||||
AddressBarPnl.Enabled := True;
|
||||
GoBtn.Click;
|
||||
end;
|
||||
|
||||
procedure TJSEvalFrm.BrowserDestroyMsg(var aMessage : TMessage);
|
||||
begin
|
||||
CEFWindowParent1.Free;
|
||||
end;
|
||||
|
||||
procedure TJSEvalFrm.ShowTextViewerMsg(var aMessage : TMessage);
|
||||
begin
|
||||
SimpleTextViewerFrm.Memo1.Lines.Text := FText;
|
||||
SimpleTextViewerFrm.ShowModal;
|
||||
end;
|
||||
|
||||
procedure TJSEvalFrm.Timer1Timer(Sender: TObject);
|
||||
begin
|
||||
Timer1.Enabled := False;
|
||||
if not(Chromium1.CreateBrowser(CEFWindowParent1, '')) and not(Chromium1.Initialized) then
|
||||
Timer1.Enabled := True;
|
||||
end;
|
||||
|
||||
procedure TJSEvalFrm.WMMove(var aMessage : TWMMove);
|
||||
begin
|
||||
inherited;
|
||||
|
||||
if (Chromium1 <> nil) then Chromium1.NotifyMoveOrResizeStarted;
|
||||
end;
|
||||
|
||||
procedure TJSEvalFrm.WMMoving(var aMessage : TMessage);
|
||||
begin
|
||||
inherited;
|
||||
|
||||
if (Chromium1 <> nil) then Chromium1.NotifyMoveOrResizeStarted;
|
||||
end;
|
||||
|
||||
procedure TJSEvalFrm.WMEnterMenuLoop(var aMessage: TMessage);
|
||||
begin
|
||||
inherited;
|
||||
|
||||
if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := True;
|
||||
end;
|
||||
|
||||
procedure TJSEvalFrm.WMExitMenuLoop(var aMessage: TMessage);
|
||||
begin
|
||||
inherited;
|
||||
|
||||
if (aMessage.wParam = 0) and (GlobalCEFApp <> nil) then GlobalCEFApp.OsmodalLoop := False;
|
||||
end;
|
||||
|
||||
procedure TJSEvalFrm.EvalJSCodeMsg(var aMessage : TMessage);
|
||||
var
|
||||
TempMsg : ICefProcessMessage;
|
||||
TempScript : string;
|
||||
begin
|
||||
TempScript := InputBox('JSEval demo', 'Please type some JavaScript code', 'document.title;');
|
||||
|
||||
if (length(TempScript) > 0) then
|
||||
begin
|
||||
TempMsg := TCefProcessMessageRef.New(EVAL_JS);
|
||||
|
||||
if TempMsg.ArgumentList.SetString(0, TempScript) then
|
||||
Chromium1.SendProcessMessage(PID_RENDERER, TempMsg);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TJSEvalFrm.GetScrollPosMsg(var aMessage : TMessage);
|
||||
var
|
||||
TempMsg : ICefProcessMessage;
|
||||
begin
|
||||
TempMsg := TCefProcessMessageRef.New(EVAL_JS);
|
||||
|
||||
if TempMsg.ArgumentList.SetString(0, 'window.pageYOffset') then
|
||||
Chromium1.SendProcessMessage(PID_RENDERER, TempMsg);
|
||||
end;
|
||||
|
||||
procedure TJSEvalFrm.EvalJSBinParamMsg(var aMessage : TMessage);
|
||||
var
|
||||
TempMsg : ICefProcessMessage;
|
||||
TempOpenDialog : TOpenDialog;
|
||||
TempStream : TFileStream;
|
||||
TempBinValue : ICefBinaryValue;
|
||||
TempBuffer : TBytes;
|
||||
TempSize : NativeUInt;
|
||||
TempPointer : pointer;
|
||||
begin
|
||||
TempOpenDialog := nil;
|
||||
TempStream := nil;
|
||||
|
||||
try
|
||||
try
|
||||
TempOpenDialog := TOpenDialog.Create(nil);
|
||||
TempOpenDialog.Options := TempOpenDialog.Options + [ofFileMustExist];
|
||||
TempOpenDialog.Filter := 'JPEG files (*.jpg)|*.JPG';
|
||||
|
||||
if TempOpenDialog.Execute then
|
||||
begin
|
||||
TempStream := TFileStream.Create(TempOpenDialog.FileName, fmOpenRead);
|
||||
TempSize := TempStream.Size;
|
||||
|
||||
if (TempSize > 0) then
|
||||
begin
|
||||
SetLength(TempBuffer, TempSize);
|
||||
TempSize := TempStream.Read(TempBuffer[0], TempSize);
|
||||
|
||||
if (TempSize > 0) then
|
||||
begin
|
||||
TempPointer := @TempBuffer[0];
|
||||
TempBinValue := TCefBinaryValueRef.New(TempPointer, TempSize);
|
||||
TempMsg := TCefProcessMessageRef.New(BINARY_PARAM_JS);
|
||||
|
||||
if TempMsg.ArgumentList.SetBinary(0, TempBinValue) then
|
||||
Chromium1.SendProcessMessage(PID_RENDERER, TempMsg);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('TJSEvalFrm.EvalJSBinParamMsg', e) then raise;
|
||||
end;
|
||||
finally
|
||||
if (TempOpenDialog <> nil) then FreeAndNil(TempOpenDialog);
|
||||
if (TempStream <> nil) then FreeAndNil(TempStream);
|
||||
SetLength(TempBuffer, 0);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure ParseEvalJsAnswer(const pMessage : ICefProcessMessage;
|
||||
const pBrowser : ICefBrowser;
|
||||
const pFrame : ICefFrame;
|
||||
const pReturnValue : ICefv8Value;
|
||||
const pException : ICefV8Exception);
|
||||
var
|
||||
pAnswer : ICefProcessMessage;
|
||||
strResult : String;
|
||||
bGoodDataType : Boolean;
|
||||
begin
|
||||
pAnswer := TCefProcessMessageRef.New(EVAL_JS);
|
||||
|
||||
if (pReturnValue = nil) or not(pReturnValue.IsValid) then
|
||||
begin
|
||||
pAnswer.ArgumentList.SetBool(0, false);
|
||||
pAnswer.ArgumentList.SetString(1, pException.Message);
|
||||
end
|
||||
else
|
||||
begin
|
||||
bGoodDataType := True;
|
||||
|
||||
if pReturnValue.IsString then strResult := pReturnValue.GetStringValue
|
||||
else if pReturnValue.IsBool then strResult := BoolToStr(pReturnValue.GetBoolValue)
|
||||
else if pReturnValue.IsInt then strResult := IntToStr(pReturnValue.GetIntValue)
|
||||
else if pReturnValue.IsUInt then strResult := IntToStr(pReturnValue.GetUIntValue)
|
||||
else if pReturnValue.IsDouble then strResult := FloatToStr(pReturnValue.GetDoubleValue)
|
||||
else bGoodDataType := False;
|
||||
|
||||
if bGoodDataType then
|
||||
begin
|
||||
pAnswer.ArgumentList.SetBool(0, true);
|
||||
pAnswer.ArgumentList.SetString(1, strResult);
|
||||
end
|
||||
else
|
||||
begin
|
||||
pAnswer.ArgumentList.SetBool(0, false);
|
||||
pAnswer.ArgumentList.SetString(1, 'Result data type need to be string, int, uint or double!');
|
||||
end;
|
||||
end;
|
||||
|
||||
if (pFrame <> nil) and pFrame.IsValid then
|
||||
pFrame.SendProcessMessage(PID_BROWSER, pAnswer);
|
||||
end;
|
||||
|
||||
procedure ParseBinaryValue(const pBrowser : ICefBrowser; const pFrame: ICefFrame; const aBinaryValue : ICefBinaryValue);
|
||||
var
|
||||
pAnswer : ICefProcessMessage;
|
||||
TempBuffer : TBytes;
|
||||
TempPointer : pointer;
|
||||
TempSize : NativeUInt;
|
||||
TempString : string;
|
||||
TempDecodedStream : TBytesStream;
|
||||
TempEncodedStream : TStringStream;
|
||||
TempEncoder : TBase64EncodingStream;
|
||||
begin
|
||||
TempDecodedStream := nil;
|
||||
TempEncodedStream := nil;
|
||||
TempEncoder := nil;
|
||||
|
||||
if (aBinaryValue = nil) then exit;
|
||||
|
||||
try
|
||||
try
|
||||
TempSize := aBinaryValue.GetSize;
|
||||
|
||||
if (TempSize > 0) then
|
||||
begin
|
||||
SetLength(TempBuffer, TempSize);
|
||||
TempPointer := @TempBuffer[0];
|
||||
TempSize := aBinaryValue.GetData(TempPointer, TempSize, 0);
|
||||
|
||||
if (TempSize > 0) then
|
||||
begin
|
||||
TempDecodedStream := TBytesStream.Create(TempBuffer);
|
||||
|
||||
TempEncodedStream := TStringStream.Create('');
|
||||
TempEncoder := TBase64EncodingStream.Create(TempEncodedStream);
|
||||
TempEncoder.CopyFrom(TempDecodedStream, TempDecodedStream.Size);
|
||||
|
||||
pAnswer := TCefProcessMessageRef.New(BINARY_PARAM_JS);
|
||||
TempString := 'Image size : ' + inttostr(TempSize) + #13 + #10 +
|
||||
'Encoded image : ' + TempEncodedStream.DataString;
|
||||
|
||||
if (pFrame <> nil) and pFrame.IsValid and pAnswer.ArgumentList.SetString(0, TempString) then
|
||||
pFrame.SendProcessMessage(PID_BROWSER, pAnswer);
|
||||
end;
|
||||
end;
|
||||
except
|
||||
on e : exception do
|
||||
if CustomExceptionHandler('ParseBinaryValue', e) then raise;
|
||||
end;
|
||||
finally
|
||||
if (TempDecodedStream <> nil) then FreeAndnil(TempDecodedStream);
|
||||
if (TempEncodedStream <> nil) then FreeAndnil(TempEncodedStream);
|
||||
if (TempEncoder <> nil) then FreeAndnil(TempEncoder);
|
||||
SetLength(TempBuffer, 0);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure RenderProcessHandler_OnProcessMessageReceivedEvent(const pBrowser : ICefBrowser;
|
||||
const pFrame : ICefFrame;
|
||||
uSourceProcess : TCefProcessId;
|
||||
const pMessage : ICefProcessMessage;
|
||||
var aHandled : boolean);
|
||||
var
|
||||
pV8Context : ICefv8Context;
|
||||
pReturnValue : ICefv8Value;
|
||||
pException : ICefV8Exception;
|
||||
TempScript : string;
|
||||
TempBinValue : ICefBinaryValue;
|
||||
begin
|
||||
aHandled := False;
|
||||
|
||||
if (pMessage = nil) or (pMessage.ArgumentList = nil) then exit;
|
||||
|
||||
if (pMessage.Name = EVAL_JS) then
|
||||
begin
|
||||
TempScript := pMessage.ArgumentList.GetString(0);
|
||||
|
||||
if (length(TempScript) > 0) and (pFrame <> nil) and pFrame.IsValid then
|
||||
begin
|
||||
pV8Context := pFrame.GetV8Context;
|
||||
|
||||
if pV8Context.Enter then
|
||||
begin
|
||||
pV8Context.Eval(TempScript, '', 1, pReturnValue, pException);
|
||||
ParseEvalJsAnswer(pMessage, pBrowser, pFrame, pReturnValue, pException);
|
||||
pV8Context.Exit;
|
||||
end;
|
||||
end;
|
||||
|
||||
aHandled := True;
|
||||
end
|
||||
else
|
||||
if (pMessage.Name = BINARY_PARAM_JS) then
|
||||
begin
|
||||
TempBinValue := pMessage.ArgumentList.GetBinary(0);
|
||||
ParseBinaryValue(pBrowser, pFrame, TempBinValue);
|
||||
aHandled := True;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure CreateGlobalCEFApp;
|
||||
begin
|
||||
GlobalCEFApp := TCefApplication.Create;
|
||||
GlobalCEFApp.OnProcessMessageReceived := RenderProcessHandler_OnProcessMessageReceivedEvent;
|
||||
end;
|
||||
|
||||
procedure TJSEvalFrm.Chromium1ProcessMessageReceived(Sender : TObject;
|
||||
const browser : ICefBrowser;
|
||||
const frame : ICefFrame;
|
||||
sourceProcess : TCefProcessId;
|
||||
const message : ICefProcessMessage;
|
||||
out Result : Boolean);
|
||||
begin
|
||||
Result := False;
|
||||
|
||||
if (message = nil) or (message.ArgumentList = nil) then exit;
|
||||
|
||||
if (message.Name = EVAL_JS) then
|
||||
begin
|
||||
FText := message.ArgumentList.GetString(1);
|
||||
PostMessage(Handle, MINIBROWSER_SHOWTEXTVIEWER, 0, 0);
|
||||
Result := True;
|
||||
end
|
||||
else
|
||||
if (message.Name = BINARY_PARAM_JS) then
|
||||
begin
|
||||
FText := message.ArgumentList.GetString(0);
|
||||
PostMessage(Handle, MINIBROWSER_SHOWTEXTVIEWER, 0, 0);
|
||||
Result := True;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
@ -0,0 +1,27 @@
|
||||
object SimpleTextViewerFrm: TSimpleTextViewerFrm
|
||||
Left = 0
|
||||
Height = 572
|
||||
Top = 0
|
||||
Width = 694
|
||||
BorderIcons = [biSystemMenu]
|
||||
BorderStyle = bsSingle
|
||||
Caption = 'Simple text viewer'
|
||||
ClientHeight = 572
|
||||
ClientWidth = 694
|
||||
Color = clBtnFace
|
||||
Font.Color = clWindowText
|
||||
Font.Height = -11
|
||||
Font.Name = 'Tahoma'
|
||||
Position = poScreenCenter
|
||||
LCLVersion = '2.0.1.0'
|
||||
object Memo1: TMemo
|
||||
Left = 0
|
||||
Height = 572
|
||||
Top = 0
|
||||
Width = 694
|
||||
Align = alClient
|
||||
ReadOnly = True
|
||||
ScrollBars = ssBoth
|
||||
TabOrder = 0
|
||||
end
|
||||
end
|
@ -0,0 +1,33 @@
|
||||
unit uSimpleTextViewer;
|
||||
|
||||
{$MODE Delphi}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
{$IFDEF DELPHI16_UP}
|
||||
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
|
||||
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
|
||||
{$ELSE}
|
||||
LCLIntf, LCLType, LMessages, Messages, SysUtils, Variants, Classes, Graphics,
|
||||
Controls, Forms, Dialogs, StdCtrls;
|
||||
{$ENDIF}
|
||||
|
||||
|
||||
type
|
||||
TSimpleTextViewerFrm = class(TForm)
|
||||
Memo1: TMemo;
|
||||
private
|
||||
{ Private declarations }
|
||||
public
|
||||
{ Public declarations }
|
||||
end;
|
||||
|
||||
var
|
||||
SimpleTextViewerFrm: TSimpleTextViewerFrm;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
end.
|
Reference in New Issue
Block a user