1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2024-11-24 08:02:15 +02:00

Update to CEF 3.3497.1829.g004ef91

- Added the TCEFLinkedWindowParent component.
This commit is contained in:
Salvador Díaz Fau 2018-09-16 10:39:41 +02:00
parent 8ebb5fb527
commit 0cf7c5f6b3
26 changed files with 477 additions and 271 deletions

View File

@ -52,7 +52,7 @@ object SchemeRegistrationBrowserFrm: TSchemeRegistrationBrowserFrm
Align = alClient
ItemIndex = 1
TabOrder = 1
Text = 'hello://test.html'
Text = 'hello://simplexsl.xml'
Items.Strings = (
'https://www.google.com'
'hello://test.html')

View File

@ -23,6 +23,7 @@ object Form1: TForm1
Width = 1038
Height = 594
Align = alClient
TabStop = True
TabOrder = 0
OnClose = ChromiumWindow1Close
OnBeforeClose = ChromiumWindow1BeforeClose

View File

@ -49,7 +49,8 @@ uses
Windows, Messages, SysUtils, Variants, Classes, Graphics,
Controls, Forms, Dialogs, StdCtrls, ExtCtrls,
{$ENDIF}
uCEFChromium, uCEFWindowParent, uCEFChromiumWindow, uCEFTypes, uCEFInterfaces;
uCEFChromium, uCEFWindowParent, uCEFChromiumWindow, uCEFTypes, uCEFInterfaces,
uCEFWinControl;
type
TForm1 = class(TForm)

View File

@ -8,10 +8,10 @@
<Unit0>
<Filename Value="SimpleLazOSRBrowser.lpr"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="-1"/>
<TopLine Value="31"/>
<CursorPos X="10" Y="43"/>
<UsageCount Value="40"/>
<Loaded Value="True"/>
<DefaultSyntaxHighlighter Value="Delphi"/>
</Unit0>
<Unit1>
@ -20,7 +20,7 @@
<ComponentName Value="Form1"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<EditorIndex Value="2"/>
<EditorIndex Value="-1"/>
<TopLine Value="186"/>
<CursorPos X="15" Y="191"/>
<UsageCount Value="40"/>
@ -28,8 +28,6 @@
<Item0 Y="189" ID="1"/>
<Item1 X="5" Y="805" ID="2"/>
</Bookmarks>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
<DefaultSyntaxHighlighter Value="Delphi"/>
</Unit1>
<Unit2>
@ -44,11 +42,10 @@
</Unit2>
<Unit3>
<Filename Value="..\..\source\uBufferPanel.pas"/>
<EditorIndex Value="1"/>
<EditorIndex Value="-1"/>
<TopLine Value="95"/>
<CursorPos X="41" Y="126"/>
<UsageCount Value="17"/>
<Loaded Value="True"/>
</Unit3>
<Unit4>
<Filename Value="..\..\..\..\lcl\lcltype.pp"/>
@ -106,11 +103,10 @@
</Unit10>
<Unit11>
<Filename Value="..\..\source\uCEFMiscFunctions.pas"/>
<EditorIndex Value="3"/>
<EditorIndex Value="-1"/>
<TopLine Value="1220"/>
<CursorPos Y="1231"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit11>
<Unit12>
<Filename Value="..\..\source\uCEFConstants.pas"/>
@ -159,126 +155,15 @@
<Unit18>
<Filename Value="..\..\source\uCEFApplication.pas"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="4"/>
<EditorIndex Value="-1"/>
<TopLine Value="839"/>
<CursorPos X="58" Y="846"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit18>
</Units>
<JumpHistory Count="28" HistoryIndex="27">
<Position1>
<Filename Value="..\..\source\uBufferPanel.pas"/>
<Caret Line="163" Column="28" TopLine="43"/>
</Position1>
<Position2>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="800" Column="81" TopLine="787"/>
</Position2>
<Position3>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="191" Column="3" TopLine="180"/>
</Position3>
<Position4>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="78" Column="25" TopLine="73"/>
</Position4>
<Position5>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="789" TopLine="788"/>
</Position5>
<Position6>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="203" Column="48" TopLine="173"/>
</Position6>
<Position7>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="800" Column="5" TopLine="785"/>
</Position7>
<Position8>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="190" TopLine="172"/>
</Position8>
<Position9>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="78" TopLine="62"/>
</Position9>
<Position10>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="191" Column="23" TopLine="188"/>
</Position10>
<Position11>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="197" Column="53" TopLine="185"/>
</Position11>
<Position12>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="206" Column="76" TopLine="179"/>
</Position12>
<Position13>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="76" Column="15" TopLine="61"/>
</Position13>
<Position14>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="814" Column="3" TopLine="810"/>
</Position14>
<Position15>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="78" Column="15" TopLine="59"/>
</Position15>
<Position16>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="203" Column="68" TopLine="188"/>
</Position16>
<Position17>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="206" Column="66" TopLine="188"/>
</Position17>
<Position18>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="196" TopLine="186"/>
</Position18>
<Position19>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="198" TopLine="186"/>
</Position19>
<Position20>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="200" TopLine="186"/>
</Position20>
<Position21>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="196" Column="47" TopLine="186"/>
</Position21>
<Position22>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="195" TopLine="186"/>
</Position22>
<Position23>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="197" TopLine="186"/>
</Position23>
<Position24>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="199" TopLine="186"/>
</Position24>
<Position25>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="200" TopLine="186"/>
</Position25>
<Position26>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="201" TopLine="186"/>
</Position26>
<Position27>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="191" Column="15" TopLine="186"/>
</Position27>
<Position28>
<Filename Value="..\..\source\uCEFMiscFunctions.pas"/>
<Caret Line="1231" TopLine="1220"/>
</Position28>
</JumpHistory>
<General>
<ActiveWindowIndexAtStart Value="-1"/>
</General>
<JumpHistory HistoryIndex="-1"/>
</ProjectSession>
</CONFIG>

View File

@ -4,13 +4,13 @@
<PathDelim Value="\"/>
<Version Value="10"/>
<BuildModes Active="Default"/>
<Units Count="34">
<Units Count="36">
<Unit0>
<Filename Value="SimpleLazarusBrowser.lpr"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="-1"/>
<TopLine Value="7"/>
<CursorPos X="47" Y="22"/>
<TopLine Value="5"/>
<CursorPos X="43" Y="5"/>
<UsageCount Value="38"/>
</Unit0>
<Unit1>
@ -138,7 +138,8 @@
</Unit16>
<Unit17>
<Filename Value="..\..\source\uCEFApplication.pas"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="-1"/>
<WindowIndex Value="-1"/>
<TopLine Value="2169"/>
<CursorPos Y="44"/>
<UsageCount Value="13"/>
@ -146,7 +147,6 @@
<Item0 X="60" Y="956" ID="1"/>
<Item1 X="9" Y="894" ID="3"/>
</Bookmarks>
<Loaded Value="True"/>
</Unit17>
<Unit18>
<Filename Value="C:\lazarus\lcl\forms.pp"/>
@ -264,6 +264,22 @@
<CursorPos X="3" Y="338"/>
<UsageCount Value="10"/>
</Unit33>
<Unit34>
<Filename Value="..\..\packages\cef4delphi_lazarus.pas"/>
<UnitName Value="CEF4Delphi_Lazarus"/>
<EditorIndex Value="-1"/>
<TopLine Value="50"/>
<CursorPos X="16" Y="62"/>
<UsageCount Value="10"/>
</Unit34>
<Unit35>
<Filename Value="..\..\source\uCEFLinkedWindowParent.pas"/>
<IsVisibleTab Value="True"/>
<TopLine Value="31"/>
<CursorPos X="28" Y="38"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit35>
</Units>
<JumpHistory HistoryIndex="-1"/>
</ProjectSession>

View File

@ -162,7 +162,9 @@ contains
uCEFServerEvents in '..\source\uCEFServerEvents.pas',
uCEFServerComponent in '..\source\uCEFServerComponent.pas',
uCEFStringList in '..\source\uCEFStringList.pas',
uCEFv8ArrayBufferReleaseCallback in '..\source\uCEFv8ArrayBufferReleaseCallback.pas';
uCEFv8ArrayBufferReleaseCallback in '..\source\uCEFv8ArrayBufferReleaseCallback.pas',
uCEFWinControl in '..\source\uCEFWinControl.pas',
uCEFLinkedWindowParent in '..\source\uCEFLinkedWindowParent.pas';
end.

View File

@ -254,6 +254,8 @@
<DCCReference Include="..\source\uCEFServerComponent.pas"/>
<DCCReference Include="..\source\uCEFStringList.pas"/>
<DCCReference Include="..\source\uCEFv8ArrayBufferReleaseCallback.pas"/>
<DCCReference Include="..\source\uCEFWinControl.pas"/>
<DCCReference Include="..\source\uCEFLinkedWindowParent.pas"/>
<BuildConfiguration Include="Base">
<Key>Base</Key>
</BuildConfiguration>

View File

@ -159,6 +159,8 @@ contains
uCEFServerEvents in '..\source\uCEFServerEvents.pas',
uCEFServerComponent in '..\source\uCEFServerComponent.pas',
uCEFStringList in '..\source\uCEFStringList.pas',
uCEFv8ArrayBufferReleaseCallback in '..\source\uCEFv8ArrayBufferReleaseCallback.pas';
uCEFv8ArrayBufferReleaseCallback in '..\source\uCEFv8ArrayBufferReleaseCallback.pas',
uCEFWinControl in '..\source\uCEFWinControl.pas',
uCEFLinkedWindowParent in '..\source\uCEFLinkedWindowParent.pas';
end.

View File

@ -49,12 +49,13 @@ implementation
uses
Classes,
uCEFChromium, uCEFWindowParent, uCEFChromiumWindow, uBufferPanel, uCEFWorkScheduler, uCEFServerComponent;
uCEFChromium, uCEFWindowParent, uCEFChromiumWindow, uBufferPanel, uCEFWorkScheduler,
uCEFServerComponent, uCEFLinkedWindowParent;
procedure Register;
begin
RegisterComponents('Chromium', [TChromium, TCEFWindowParent, TChromiumWindow, TBufferPanel,
TCEFWorkScheduler, TCEFServerComponent]);
TCEFWorkScheduler, TCEFServerComponent, TCEFLinkedWindowParent]);
end;
end.

View File

@ -12,18 +12,17 @@ package CEF4Delphi_FMX;
{$LOCALSYMBOLS ON}
{$LONGSTRINGS ON}
{$OPENSTRINGS ON}
{$OPTIMIZATION OFF}
{$OPTIMIZATION ON}
{$OVERFLOWCHECKS ON}
{$RANGECHECKS ON}
{$REFERENCEINFO ON}
{$SAFEDIVIDE OFF}
{$STACKFRAMES ON}
{$STACKFRAMES OFF}
{$TYPEDADDRESS OFF}
{$VARSTRINGCHECKS ON}
{$WRITEABLECONST OFF}
{$MINENUMSIZE 1}
{$IMAGEBASE $400000}
{$DEFINE DEBUG}
{$ENDIF IMPLICITBUILDING}
{$DESCRIPTION 'CEF4Delphi'}
{$IMPLICITBUILD OFF}
@ -167,7 +166,9 @@ contains
uFMXWorkScheduler in '..\source\uFMXWorkScheduler.pas',
uCEFStringList in '..\source\uCEFStringList.pas',
uFMXWindowParent in '..\source\uFMXWindowParent.pas',
uCEFv8ArrayBufferReleaseCallback in '..\source\uCEFv8ArrayBufferReleaseCallback.pas';
uCEFv8ArrayBufferReleaseCallback in '..\source\uCEFv8ArrayBufferReleaseCallback.pas',
uCEFWinControl in '..\source\uCEFWinControl.pas',
uCEFLinkedWindowParent in '..\source\uCEFLinkedWindowParent.pas';
end.

View File

@ -268,6 +268,8 @@
<DCCReference Include="..\source\uCEFStringList.pas"/>
<DCCReference Include="..\source\uFMXWindowParent.pas"/>
<DCCReference Include="..\source\uCEFv8ArrayBufferReleaseCallback.pas"/>
<DCCReference Include="..\source\uCEFWinControl.pas"/>
<DCCReference Include="..\source\uCEFLinkedWindowParent.pas"/>
<BuildConfiguration Include="Base">
<Key>Base</Key>
</BuildConfiguration>

Binary file not shown.

View File

@ -49,14 +49,16 @@ implementation
uses
System.Classes,
uCEFChromium, uCEFWindowParent, uCEFChromiumWindow, uBufferPanel, uCEFWorkScheduler,
uFMXBufferPanel, uFMXChromium, uFMXWorkScheduler, uCEFServerComponent;
uCEFChromium, uCEFWindowParent, uCEFChromiumWindow, uBufferPanel,
uCEFWorkScheduler, uFMXBufferPanel, uFMXChromium, uFMXWorkScheduler,
uCEFServerComponent, uCEFLinkedWindowParent;
procedure Register;
begin
RegisterComponents('Chromium', [TChromium, TCEFWindowParent, TChromiumWindow, TBufferPanel,
TFMXBufferPanel, TFMXChromium, TFMXWorkScheduler,
TCEFWorkScheduler, TCEFServerComponent]);
RegisterComponents('Chromium', [TChromium, TCEFWindowParent, TChromiumWindow,
TBufferPanel, TFMXBufferPanel, TFMXChromium,
TFMXWorkScheduler, TCEFWorkScheduler,
TCEFServerComponent, TCEFLinkedWindowParent]);
end;
end.

View File

@ -54,12 +54,12 @@ uses
Classes,
{$ENDIF}
uCEFChromium, uCEFWindowParent, uCEFChromiumWindow, uBufferPanel, uCEFWorkScheduler,
uCEFServerComponent;
uCEFServerComponent, uCEFLinkedWindowParent;
procedure Register;
begin
RegisterComponents('Chromium', [TChromium, TCEFWindowParent, TChromiumWindow, TBufferPanel,
TCEFWorkScheduler, TCEFServerComponent]);
TCEFWorkScheduler, TCEFServerComponent, TCEFLinkedWindowParent]);
end;
end.

View File

@ -21,7 +21,7 @@
</CompilerOptions>
<Description Value="CEF4Delphi"/>
<Version Major="1"/>
<Files Count="133">
<Files Count="135">
<Item1>
<Filename Value="..\source\uCEFAccessibilityHandler.pas"/>
<UnitName Value="uCEFAccessibilityHandler"/>
@ -560,6 +560,15 @@
<Filename Value="..\source\res\tchromiumwindow.lrs"/>
<Type Value="LRS"/>
</Item133>
<Item134>
<Filename Value="..\source\uCEFWinControl.pas"/>
<UnitName Value="uCEFWinControl"/>
</Item134>
<Item135>
<Filename Value="..\source\uCEFLinkedWindowParent.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="uCEFLinkedWindowParent"/>
</Item135>
</Files>
<RequiredPkgs Count="3">
<Item1>

View File

@ -45,7 +45,8 @@ uses
uCEFWindowParent, uCEFWorkScheduler, uCEFWorkSchedulerThread,
uCEFWriteHandler, uCEFX509Certificate, uCEFX509CertPrincipal, uCEFXmlReader,
uCEFZipReader, uCEFChromium, uBufferPanel, uCEFServer, uCEFServerComponent,
uCEFServerEvents, uCEFServerHandler, LazarusPackageIntf;
uCEFServerEvents, uCEFServerHandler, uCEFWinControl, uCEFLinkedWindowParent,
LazarusPackageIntf;
implementation
@ -57,6 +58,7 @@ begin
RegisterUnit('uCEFChromium', @uCEFChromium.Register);
RegisterUnit('uBufferPanel', @uBufferPanel.Register);
RegisterUnit('uCEFServerComponent', @uCEFServerComponent.Register);
RegisterUnit('uCEFLinkedWindowParent', @uCEFLinkedWindowParent.Register);
end;
initialization

View File

@ -1,7 +1,8 @@
e:\lazarus\tools\lazres.exe ..\..\source\res\tbufferpanel.lrs tbufferpanel.png
e:\lazarus\tools\lazres.exe ..\..\source\res\tcefservercomponent.lrs tcefservercomponent.png
e:\lazarus\tools\lazres.exe ..\..\source\res\tcefwindowparent.lrs tcefwindowparent.png
e:\lazarus\tools\lazres.exe ..\..\source\res\tcefworkscheduler.lrs tcefworkscheduler.png
e:\lazarus\tools\lazres.exe ..\..\source\res\tchromium.lrs tchromium.png
e:\lazarus\tools\lazres.exe ..\..\source\res\tchromiumwindow.lrs tchromiumwindow.png
c:\lazarus\tools\lazres.exe ..\..\source\res\tbufferpanel.lrs tbufferpanel.png
c:\lazarus\tools\lazres.exe ..\..\source\res\tcefservercomponent.lrs tcefservercomponent.png
c:\lazarus\tools\lazres.exe ..\..\source\res\tcefwindowparent.lrs tcefwindowparent.png
c:\lazarus\tools\lazres.exe ..\..\source\res\tceflinkedwindowparent.lrs tceflinkedwindowparent.png
c:\lazarus\tools\lazres.exe ..\..\source\res\tcefworkscheduler.lrs tcefworkscheduler.png
c:\lazarus\tools\lazres.exe ..\..\source\res\tchromium.lrs tchromium.png
c:\lazarus\tools\lazres.exe ..\..\source\res\tchromiumwindow.lrs tchromiumwindow.png
pause

Binary file not shown.

View File

@ -1,6 +1,7 @@
TChromium BITMAP "chromium.bmp"
TFMXChromium BITMAP "chromium.bmp"
TCEFWindowParent BITMAP "windowparent.bmp"
TCEFLinkedWindowParent BITMAP "windowparent.bmp"
TChromiumWindow BITMAP "chromiumwindow.bmp"
TBufferPanel BITMAP "bufferpanel.bmp"
TFMXBufferPanel BITMAP "bufferpanel.bmp"

Binary file not shown.

After

Width:  |  Height:  |  Size: 271 B

View File

@ -0,0 +1,13 @@
LazarusResources.Add('tceflinkedwindowparent','PNG',[
#137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#2#0#0#0'o'#21#170#175
+#0#0#0#9'pHYs'#0#0#13#215#0#0#13#215#1'B('#155'x'#0#0#0#7'tIME'#7#226#5#11#10
+#31'&'#154'y'#22#237#0#0#0#174'IDAT8'#203#173#148';'#14#196' '#12'D'#241#136
+#130#179' q'#255'+'#144#27#228#20'i'#144#136#20'18'#5#171#253#148#27#219#189
+#159#158#199#150'EU'#131'G'#197#214#218#190#239'FJ'#206'9'#212'ZI'#170#161'H'
+#214'ZA'#18#128'E'#7#0'I'#4#167'r'#3#197#16#194#156#211#7#180'2{'#140#16#145
+#143#145#15'HU-'#211#173#165#199'E!i'#9'HU_'#163'Y'#140#188'G'#179#27#173#222
+#184'('#150#140#0#204'9'#253#140#236#25#173#27't52f'#244#3#178#27#249#189#145
+#235#186#0#164#148','#151#221'{'#151#227'8'#182'm;'#207's'#140#241#239#15#16
+#17#17'I)'#149'R'#228#187#249'AR'#239#127#127#3#232'x'#222'a'#127#10#207#215
+#0#0#0#0'IEND'#174'B`'#130
]);

View File

@ -61,7 +61,7 @@ uses
const
CEF_SUPPORTED_VERSION_MAJOR = 3;
CEF_SUPPORTED_VERSION_MINOR = 3497;
CEF_SUPPORTED_VERSION_RELEASE = 1827;
CEF_SUPPORTED_VERSION_RELEASE = 1829;
CEF_SUPPORTED_VERSION_BUILD = 0;
CEF_CHROMEELF_VERSION_MAJOR = 69;

View File

@ -52,7 +52,7 @@ interface
uses
{$IFDEF DELPHI16_UP}
{$IFDEF MSWINDOWS}WinApi.Windows, WinApi.Messages,{$ENDIF} System.Classes,
{$IFDEF MSWINDOWS}WinApi.Windows, WinApi.Messages,{$ENDIF} System.Classes, Vcl.Controls,
{$ELSE}
{$IFDEF MSWINDOWS}Windows,{$ENDIF} Classes, Forms, Controls, Graphics,
{$IFDEF FPC}
@ -61,18 +61,20 @@ uses
Messages,
{$ENDIF}
{$ENDIF}
uCEFWindowParent, uCEFChromium, uCEFInterfaces, uCEFConstants, uCEFTypes;
uCEFWindowParent, uCEFChromium, uCEFInterfaces, uCEFConstants, uCEFTypes, uCEFWinControl;
type
TChromiumWindow = class(TCEFWindowParent)
TChromiumWindow = class(TCEFWinControl)
protected
FChromium : TChromium;
FOnClose : TNotifyEvent;
FOnBeforeClose : TNotifyEvent;
FOnAfterCreated : TNotifyEvent;
function GetChildWindowHandle : THandle; override;
function GetBrowserInitialized : boolean;
function GetChildWindowHandle : THandle; override;
procedure WndProc(var aMessage: TMessage); override;
procedure OnCloseMsg(var aMessage : TMessage); message CEF_DOONCLOSE;
procedure OnBeforeCloseMsg(var aMessage : TMessage); message CEF_DOONBEFORECLOSE;
@ -144,6 +146,39 @@ begin
if (Result = 0) then Result := inherited GetChildWindowHandle;
end;
procedure TChromiumWindow.WndProc(var aMessage: TMessage);
var
TempHandle : THandle;
begin
case aMessage.Msg of
WM_SETFOCUS:
begin
if (FChromium <> nil) then
FChromium.SetFocus(True)
else
begin
TempHandle := ChildWindowHandle;
if (TempHandle <> 0) then PostMessage(TempHandle, WM_SETFOCUS, aMessage.WParam, 0);
end;
inherited WndProc(aMessage);
end;
WM_ERASEBKGND:
if (ChildWindowHandle = 0) then inherited WndProc(aMessage);
CM_WANTSPECIALKEY:
if not(TWMKey(aMessage).CharCode in [VK_LEFT .. VK_DOWN, VK_RETURN, VK_ESCAPE]) then
aMessage.Result := 1
else
inherited WndProc(aMessage);
WM_GETDLGCODE : aMessage.Result := DLGC_WANTARROWS or DLGC_WANTCHARS;
else inherited WndProc(aMessage);
end;
end;
function TChromiumWindow.GetBrowserInitialized : boolean;
begin
Result := (FChromium <> nil) and FChromium.Initialized;

View File

@ -0,0 +1,165 @@
// ************************************************************************
// ***************************** 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 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 uCEFLinkedWindowParent;
{$IFDEF FPC}
{$MODE OBJFPC}{$H+}
{$ENDIF}
{$IFNDEF CPUX64}
{$ALIGN ON}
{$MINENUMSIZE 4}
{$ENDIF}
{$I cef.inc}
interface
uses
{$IFDEF DELPHI16_UP}
{$IFDEF MSWINDOWS}WinApi.Windows, WinApi.Messages,{$ENDIF} System.Classes, Vcl.Controls, Vcl.Graphics,
{$ELSE}
{$IFDEF MSWINDOWS}Windows,{$ENDIF} Classes, Forms, Controls, Graphics,
{$IFDEF FPC}
LCLProc, LCLType, LCLIntf, LResources, LMessages, InterfaceBase,
{$ELSE}
Messages,
{$ENDIF}
{$ENDIF}
uCEFWinControl, uCEFTypes, uCEFInterfaces, uCEFChromium;
type
TCEFLinkedWindowParent = class(TCEFWinControl)
protected
FChromium : TChromium;
procedure SetChromium(aValue : TChromium);
function GetChildWindowHandle : THandle; override;
procedure WndProc(var aMessage: TMessage); override;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
public
constructor Create(AOwner : TComponent); override;
published
property Chromium : TChromium read FChromium write SetChromium;
end;
{$IFDEF FPC}
procedure Register;
{$ENDIF}
implementation
uses
uCEFMiscFunctions, uCEFClient, uCEFConstants;
constructor TCEFLinkedWindowParent.Create(AOwner : TComponent);
begin
inherited Create(AOwner);
FChromium := nil;
end;
function TCEFLinkedWindowParent.GetChildWindowHandle : THandle;
begin
Result := 0;
if (FChromium <> nil) then Result := FChromium.WindowHandle;
if (Result = 0) then Result := inherited GetChildWindowHandle;
end;
procedure TCEFLinkedWindowParent.WndProc(var aMessage: TMessage);
var
TempHandle : THandle;
begin
case aMessage.Msg of
WM_SETFOCUS:
begin
if (FChromium <> nil) then
FChromium.SetFocus(True)
else
begin
TempHandle := ChildWindowHandle;
if (TempHandle <> 0) then PostMessage(TempHandle, WM_SETFOCUS, aMessage.WParam, 0);
end;
inherited WndProc(aMessage);
end;
WM_ERASEBKGND:
if (ChildWindowHandle = 0) then inherited WndProc(aMessage);
CM_WANTSPECIALKEY:
if not(TWMKey(aMessage).CharCode in [VK_LEFT .. VK_DOWN, VK_RETURN, VK_ESCAPE]) then
aMessage.Result := 1
else
inherited WndProc(aMessage);
WM_GETDLGCODE : aMessage.Result := DLGC_WANTARROWS or DLGC_WANTCHARS;
else inherited WndProc(aMessage);
end;
end;
procedure TCEFLinkedWindowParent.Notification(AComponent: TComponent; Operation: TOperation);
begin
inherited Notification(AComponent, Operation);
if (Operation = opRemove) and (AComponent = FChromium) then FChromium := nil;
end;
procedure TCEFLinkedWindowParent.SetChromium(aValue : TChromium);
begin
FChromium := aValue;
if (aValue <> nil) then aValue.FreeNotification(Self);
end;
{$IFDEF FPC}
procedure Register;
begin
{$I res/tceflinkedwindowparent.lrs}
RegisterComponents('Chromium', [TCEFLinkedWindowParent]);
end;
{$ENDIF}
end.

173
source/uCEFWinControl.pas Normal file
View File

@ -0,0 +1,173 @@
// ************************************************************************
// ***************************** 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 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 uCEFWinControl;
{$IFDEF FPC}
{$MODE OBJFPC}{$H+}
{$ENDIF}
{$IFNDEF CPUX64}
{$ALIGN ON}
{$MINENUMSIZE 4}
{$ENDIF}
{$I cef.inc}
interface
uses
{$IFDEF DELPHI16_UP}
{$IFDEF MSWINDOWS}WinApi.Windows, {$ENDIF} System.Classes, Vcl.Controls, Vcl.Graphics,
{$ELSE}
{$IFDEF MSWINDOWS}Windows,{$ENDIF} Classes, Forms, Controls, Graphics,
{$IFDEF FPC}
LCLProc, LCLType, LCLIntf, LResources, InterfaceBase,
{$ENDIF}
{$ENDIF}
uCEFTypes, uCEFInterfaces;
type
TCEFWinControl = class(TWinControl)
protected
function GetChildWindowHandle : THandle; virtual;
procedure Resize; override;
public
function TakeSnapshot(var aBitmap : TBitmap) : boolean;
function DestroyChildWindow : boolean;
procedure CreateHandle; override;
procedure UpdateSize;
property ChildWindowHandle : THandle read GetChildWindowHandle;
published
property Align;
property Anchors;
property Color;
property Constraints;
property TabStop;
property TabOrder;
property Visible;
property Enabled;
property ShowHint;
property Hint;
property OnResize;
property DoubleBuffered;
{$IFDEF DELPHI12_UP}
property ParentDoubleBuffered;
{$ENDIF}
end;
implementation
uses
uCEFMiscFunctions, uCEFClient, uCEFConstants;
function TCEFWinControl.GetChildWindowHandle : THandle;
begin
if not(csDesigning in ComponentState) and HandleAllocated then
Result := GetWindow(Handle, GW_CHILD)
else
Result := 0;
end;
procedure TCEFWinControl.CreateHandle;
begin
inherited CreateHandle;
end;
procedure TCEFWinControl.UpdateSize;
var
TempRect : TRect;
TempHWND : THandle;
begin
TempHWND := ChildWindowHandle;
if (TempHWND = 0) then exit;
TempRect := GetClientRect;
SetWindowPos(TempHWND, 0,
0, 0, TempRect.right, TempRect.bottom,
SWP_NOZORDER);
end;
function TCEFWinControl.TakeSnapshot(var aBitmap : TBitmap) : boolean;
var
TempHWND : HWND;
TempDC : HDC;
TempRect : TRect;
TempWidth : Integer;
TempHeight : Integer;
begin
Result := False;
if (aBitmap = nil) then exit;
TempHWND := ChildWindowHandle;
if (TempHWND = 0) then exit;
{$IFDEF DELPHI16_UP}Winapi.{$ENDIF}Windows.GetClientRect(TempHWND, TempRect);
TempDC := GetDC(TempHWND);
TempWidth := TempRect.Right - TempRect.Left;
TempHeight := TempRect.Bottom - TempRect.Top;
aBitmap := TBitmap.Create;
aBitmap.Height := TempHeight;
aBitmap.Width := TempWidth;
Result := BitBlt(aBitmap.Canvas.Handle, 0, 0, TempWidth, TempHeight,
TempDC, 0, 0, SRCCOPY);
ReleaseDC(TempHWND, TempDC);
end;
function TCEFWinControl.DestroyChildWindow : boolean;
var
TempHWND : HWND;
begin
TempHWND := ChildWindowHandle;
Result := (TempHWND <> 0) and DestroyWindow(TempHWND);
end;
procedure TCEFWinControl.Resize;
begin
inherited Resize;
UpdateSize;
end;
end.

View File

@ -52,7 +52,7 @@ interface
uses
{$IFDEF DELPHI16_UP}
{$IFDEF MSWINDOWS}WinApi.Windows, WinApi.Messages,{$ENDIF} System.Classes, Vcl.Controls, Vcl.Graphics,
{$IFDEF MSWINDOWS}WinApi.Windows, WinApi.Messages,{$ENDIF} System.Classes, Vcl.Controls, Vcl.Graphics,
{$ELSE}
{$IFDEF MSWINDOWS}Windows,{$ENDIF} Classes, Forms, Controls, Graphics,
{$IFDEF FPC}
@ -61,39 +61,12 @@ uses
Messages,
{$ENDIF}
{$ENDIF}
uCEFTypes, uCEFInterfaces;
uCEFWinControl, uCEFTypes, uCEFInterfaces;
type
TCEFWindowParent = class(TWinControl)
TCEFWindowParent = class(TCEFWinControl)
protected
function GetChildWindowHandle : THandle; virtual;
procedure WndProc(var aMessage: TMessage); override;
public
procedure UpdateSize;
function TakeSnapshot(var aBitmap : TBitmap) : boolean;
function DestroyChildWindow : boolean;
procedure CreateHandle; override;
procedure Resize; override;
property ChildWindowHandle : THandle read GetChildWindowHandle;
published
property Align;
property Anchors;
property Color;
property Constraints;
property TabStop;
property TabOrder;
property Visible;
property Enabled;
property ShowHint;
property Hint;
property DoubleBuffered;
{$IFDEF DELPHI12_UP}
property ParentDoubleBuffered;
{$ENDIF}
end;
{$IFDEF FPC}
@ -105,47 +78,6 @@ implementation
uses
uCEFMiscFunctions, uCEFClient, uCEFConstants;
function TCEFWindowParent.GetChildWindowHandle : THandle;
begin
if not(csDesigning in ComponentState) and HandleAllocated then
Result := GetWindow(Handle, GW_CHILD)
else
Result := 0;
end;
procedure TCEFWindowParent.Resize;
begin
inherited Resize;
UpdateSize;
end;
procedure TCEFWindowParent.CreateHandle;
begin
inherited;
end;
procedure TCEFWindowParent.UpdateSize;
var
TempRect : TRect;
hdwp: THandle;
TempHandle : THandle;
begin
TempHandle := ChildWindowHandle;
if (TempHandle = 0) then Exit;
TempRect := GetClientRect;
hdwp := BeginDeferWindowPos(1);
try
hdwp := DeferWindowPos(hdwp, TempHandle, HWND_TOP,
TempRect.left, TempRect.top, TempRect.right - TempRect.left, TempRect.bottom - TempRect.top,
SWP_NOZORDER);
finally
EndDeferWindowPos(hdwp);
end;
end;
procedure TCEFWindowParent.WndProc(var aMessage: TMessage);
var
TempHandle : THandle;
@ -159,10 +91,7 @@ begin
end;
WM_ERASEBKGND:
begin
TempHandle := ChildWindowHandle;
if (TempHandle = 0) then inherited WndProc(aMessage);
end;
if (ChildWindowHandle = 0) then inherited WndProc(aMessage);
CM_WANTSPECIALKEY:
if not(TWMKey(aMessage).CharCode in [VK_LEFT .. VK_DOWN, VK_RETURN, VK_ESCAPE]) then
@ -176,43 +105,6 @@ begin
end;
end;
function TCEFWindowParent.TakeSnapshot(var aBitmap : TBitmap) : boolean;
var
TempHWND : HWND;
TempDC : HDC;
TempRect : TRect;
TempWidth : Integer;
TempHeight : Integer;
begin
Result := False;
TempHWND := ChildWindowHandle;
if (TempHWND <> 0) then
begin
{$IFDEF DELPHI16_UP}Winapi.{$ENDIF}Windows.GetClientRect(TempHWND, TempRect);
TempDC := GetDC(TempHWND);
TempWidth := TempRect.Right - TempRect.Left;
TempHeight := TempRect.Bottom - TempRect.Top;
aBitmap := TBitmap.Create;
aBitmap.Height := TempHeight;
aBitmap.Width := TempWidth;
Result := BitBlt(aBitmap.Canvas.Handle, 0, 0, TempWidth, TempHeight,
TempDC, 0, 0, SRCCOPY);
ReleaseDC(TempHWND, TempDC);
end;
end;
function TCEFWindowParent.DestroyChildWindow : boolean;
var
TempHWND : HWND;
begin
TempHWND := ChildWindowHandle;
Result := (TempHWND <> 0) and DestroyWindow(TempHWND);
end;
{$IFDEF FPC}
procedure Register;
begin