diff --git a/demos/SchemeRegistrationBrowser/uSchemeRegistrationBrowser.dfm b/demos/SchemeRegistrationBrowser/uSchemeRegistrationBrowser.dfm
index e685d44d..15e598e3 100644
--- a/demos/SchemeRegistrationBrowser/uSchemeRegistrationBrowser.dfm
+++ b/demos/SchemeRegistrationBrowser/uSchemeRegistrationBrowser.dfm
@@ -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')
diff --git a/demos/SimpleBrowser/uSimpleBrowser.dfm b/demos/SimpleBrowser/uSimpleBrowser.dfm
index 96fb4cce..6703a13c 100644
--- a/demos/SimpleBrowser/uSimpleBrowser.dfm
+++ b/demos/SimpleBrowser/uSimpleBrowser.dfm
@@ -23,6 +23,7 @@ object Form1: TForm1
Width = 1038
Height = 594
Align = alClient
+ TabStop = True
TabOrder = 0
OnClose = ChromiumWindow1Close
OnBeforeClose = ChromiumWindow1BeforeClose
diff --git a/demos/SimpleBrowser/uSimpleBrowser.pas b/demos/SimpleBrowser/uSimpleBrowser.pas
index 17fdde77..736d2f8f 100644
--- a/demos/SimpleBrowser/uSimpleBrowser.pas
+++ b/demos/SimpleBrowser/uSimpleBrowser.pas
@@ -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)
diff --git a/demos/SimpleLazOSRBrowser/SimpleLazOSRBrowser.lps b/demos/SimpleLazOSRBrowser/SimpleLazOSRBrowser.lps
index 430ff033..381d433b 100644
--- a/demos/SimpleLazOSRBrowser/SimpleLazOSRBrowser.lps
+++ b/demos/SimpleLazOSRBrowser/SimpleLazOSRBrowser.lps
@@ -8,10 +8,10 @@
+
-
@@ -20,7 +20,7 @@
-
+
@@ -28,8 +28,6 @@
-
-
@@ -44,11 +42,10 @@
-
+
-
@@ -106,11 +103,10 @@
-
+
-
@@ -159,126 +155,15 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
diff --git a/demos/SimpleLazarusBrowser/SimpleLazarusBrowser.lps b/demos/SimpleLazarusBrowser/SimpleLazarusBrowser.lps
index 91bd723c..b9460786 100644
--- a/demos/SimpleLazarusBrowser/SimpleLazarusBrowser.lps
+++ b/demos/SimpleLazarusBrowser/SimpleLazarusBrowser.lps
@@ -4,13 +4,13 @@
-
+
-
-
+
+
@@ -138,7 +138,8 @@
-
+
+
@@ -146,7 +147,6 @@
-
@@ -264,6 +264,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/packages/CEF4Delphi.dpk b/packages/CEF4Delphi.dpk
index 9bfb01c3..e49355b1 100644
--- a/packages/CEF4Delphi.dpk
+++ b/packages/CEF4Delphi.dpk
@@ -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.
diff --git a/packages/CEF4Delphi.dproj b/packages/CEF4Delphi.dproj
index 7bc0787a..a9311f4c 100644
--- a/packages/CEF4Delphi.dproj
+++ b/packages/CEF4Delphi.dproj
@@ -254,6 +254,8 @@
+
+
Base
diff --git a/packages/CEF4Delphi_D7.dpk b/packages/CEF4Delphi_D7.dpk
index e162fa95..164bdbfb 100644
--- a/packages/CEF4Delphi_D7.dpk
+++ b/packages/CEF4Delphi_D7.dpk
@@ -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.
diff --git a/packages/CEF4Delphi_D7_Register.pas b/packages/CEF4Delphi_D7_Register.pas
index 4137d9fe..a7a024f6 100644
--- a/packages/CEF4Delphi_D7_Register.pas
+++ b/packages/CEF4Delphi_D7_Register.pas
@@ -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.
diff --git a/packages/CEF4Delphi_FMX.dpk b/packages/CEF4Delphi_FMX.dpk
index f1e0d396..a60c3cd4 100644
--- a/packages/CEF4Delphi_FMX.dpk
+++ b/packages/CEF4Delphi_FMX.dpk
@@ -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.
diff --git a/packages/CEF4Delphi_FMX.dproj b/packages/CEF4Delphi_FMX.dproj
index 8731efea..efefcaeb 100644
--- a/packages/CEF4Delphi_FMX.dproj
+++ b/packages/CEF4Delphi_FMX.dproj
@@ -268,6 +268,8 @@
+
+
Base
diff --git a/packages/CEF4Delphi_FMX.res b/packages/CEF4Delphi_FMX.res
index 0b1d7bfe..2b6bf397 100644
Binary files a/packages/CEF4Delphi_FMX.res and b/packages/CEF4Delphi_FMX.res differ
diff --git a/packages/CEF4Delphi_FMX_Register.pas b/packages/CEF4Delphi_FMX_Register.pas
index 5d5c2dd1..768e7a1a 100644
--- a/packages/CEF4Delphi_FMX_Register.pas
+++ b/packages/CEF4Delphi_FMX_Register.pas
@@ -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.
diff --git a/packages/CEF4Delphi_Register.pas b/packages/CEF4Delphi_Register.pas
index 1ce23b15..df5a1682 100644
--- a/packages/CEF4Delphi_Register.pas
+++ b/packages/CEF4Delphi_Register.pas
@@ -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.
diff --git a/packages/cef4delphi_lazarus.lpk b/packages/cef4delphi_lazarus.lpk
index 90231135..6b14e342 100644
--- a/packages/cef4delphi_lazarus.lpk
+++ b/packages/cef4delphi_lazarus.lpk
@@ -21,7 +21,7 @@
-
+
@@ -560,6 +560,15 @@
+
+
+
+
+
+
+
+
+
diff --git a/packages/cef4delphi_lazarus.pas b/packages/cef4delphi_lazarus.pas
index 4b14ac9e..c24e04ee 100644
--- a/packages/cef4delphi_lazarus.pas
+++ b/packages/cef4delphi_lazarus.pas
@@ -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
diff --git a/packages/res/00-CreateLazarusResources.bat b/packages/res/00-CreateLazarusResources.bat
index 73ee3fde..72e24d44 100644
--- a/packages/res/00-CreateLazarusResources.bat
+++ b/packages/res/00-CreateLazarusResources.bat
@@ -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
\ No newline at end of file
diff --git a/packages/res/chromium.dcr b/packages/res/chromium.dcr
index 9aadbeb3..5a9e6ade 100644
Binary files a/packages/res/chromium.dcr and b/packages/res/chromium.dcr differ
diff --git a/packages/res/chromium.rc b/packages/res/chromium.rc
index ebd5fea0..9ce92170 100644
--- a/packages/res/chromium.rc
+++ b/packages/res/chromium.rc
@@ -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"
diff --git a/packages/res/tceflinkedwindowparent.png b/packages/res/tceflinkedwindowparent.png
new file mode 100644
index 00000000..e442de47
Binary files /dev/null and b/packages/res/tceflinkedwindowparent.png differ
diff --git a/source/res/tceflinkedwindowparent.lrs b/source/res/tceflinkedwindowparent.lrs
new file mode 100644
index 00000000..9c9bfb3a
--- /dev/null
+++ b/source/res/tceflinkedwindowparent.lrs
@@ -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
+]);
diff --git a/source/uCEFApplication.pas b/source/uCEFApplication.pas
index 7e975c13..b0756727 100644
--- a/source/uCEFApplication.pas
+++ b/source/uCEFApplication.pas
@@ -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;
diff --git a/source/uCEFChromiumWindow.pas b/source/uCEFChromiumWindow.pas
index 8e99a8b2..b539b9e8 100644
--- a/source/uCEFChromiumWindow.pas
+++ b/source/uCEFChromiumWindow.pas
@@ -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;
diff --git a/source/uCEFLinkedWindowParent.pas b/source/uCEFLinkedWindowParent.pas
new file mode 100644
index 00000000..a7aab03e
--- /dev/null
+++ b/source/uCEFLinkedWindowParent.pas
@@ -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
+ * 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.
diff --git a/source/uCEFWinControl.pas b/source/uCEFWinControl.pas
new file mode 100644
index 00000000..72c04a38
--- /dev/null
+++ b/source/uCEFWinControl.pas
@@ -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
+ * 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.
diff --git a/source/uCEFWindowParent.pas b/source/uCEFWindowParent.pas
index 750f7765..fc4a478a 100644
--- a/source/uCEFWindowParent.pas
+++ b/source/uCEFWindowParent.pas
@@ -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