diff --git a/packages/cef4delphi_lazarus.lpk b/packages/cef4delphi_lazarus.lpk
index 4ccd5d54..3c7462c9 100644
--- a/packages/cef4delphi_lazarus.lpk
+++ b/packages/cef4delphi_lazarus.lpk
@@ -22,7 +22,7 @@
-
+
@@ -827,6 +827,10 @@
+
+
+
+
diff --git a/packages/cef4delphi_lazarus.pas b/packages/cef4delphi_lazarus.pas
index d90e5b7b..91ef40df 100644
--- a/packages/cef4delphi_lazarus.pas
+++ b/packages/cef4delphi_lazarus.pas
@@ -65,7 +65,7 @@ uses
uCEFMediaSinkDeviceInfoCallback, uCEFJson, uCEFBitmapBitBuffer,
uCEFPrintDialogCallback, uCEFPrintHandler, uCEFPrintJobCallback,
uCEFLinuxFunctions, uCEFLinuxTypes, uCEFLinuxConstants,
- uCEFWorkSchedulerQueueThread, LazarusPackageIntf;
+ uCEFWorkSchedulerQueueThread, uCEFLinkedWinControlBase, LazarusPackageIntf;
implementation
diff --git a/packages/uCEFLinkedWinControlBase.pas b/packages/uCEFLinkedWinControlBase.pas
new file mode 100644
index 00000000..447cf791
--- /dev/null
+++ b/packages/uCEFLinkedWinControlBase.pas
@@ -0,0 +1,134 @@
+// ************************************************************************
+// ***************************** CEF4Delphi *******************************
+// ************************************************************************
+//
+// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based
+// browser in Delphi applications.
+//
+// The original license of DCEF3 still applies to CEF4Delphi.
+//
+// For more information about CEF4Delphi visit :
+// https://www.briskbard.com/index.php?lang=en&pageid=cef
+//
+// Copyright © 2021 Salvador Diaz Fau. All rights reserved.
+//
+// ************************************************************************
+// ************ vvvv Original license and comments below vvvv *************
+// ************************************************************************
+(*
+ * Delphi Chromium Embedded 3
+ *
+ * Usage allowed under the restrictions of the Lesser GNU General Public License
+ * or alternatively the restrictions of the Mozilla Public License 1.1
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+ * the specific language governing rights and limitations under the License.
+ *
+ * Unit owner : Henri Gourvest
+ * 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 uCEFLinkedWinControlBase;
+
+{$I cef.inc}
+
+{$IFDEF FPC}
+ {$MODE OBJFPC}{$H+}
+ {$IFDEF MACOSX}
+ {$ModeSwitch objectivec1}
+ {$ENDIF}
+{$ENDIF}
+
+{$IFNDEF CPUX64}{$ALIGN ON}{$ENDIF}
+{$MINENUMSIZE 4}
+
+interface
+
+uses
+ {$IFDEF DELPHI16_UP}
+ {$IFDEF MSWINDOWS}WinApi.Windows, {$ENDIF} System.Classes, Vcl.Controls, Vcl.Graphics,
+ {$ELSE}
+ {$IFDEF MSWINDOWS}Windows,{$ENDIF} Classes, Controls,
+ {$IFDEF FPC}
+ LCLProc, LCLType, LCLIntf,
+ {$ENDIF}
+ {$ENDIF}
+ uCEFTypes, uCEFInterfaces, uCEFWinControl, uCEFChromium;
+
+type
+
+ { TCEFLinkedWinControlBase }
+
+ TCEFLinkedWinControlBase = class(TCEFWinControl)
+ protected
+ function GetChromium: TChromium; virtual; abstract;
+
+ {$IFDEF FPC}
+ procedure SetVisible(Value: Boolean); override;
+ {$ENDIF}
+ function GetChildWindowHandle : {$IFNDEF MSWINDOWS}{$IFDEF FPC}LclType.{$ENDIF}{$ENDIF}THandle; override;
+
+ property Chromium : TChromium read GetChromium;
+ public
+ procedure UpdateSize; override;
+ end;
+
+implementation
+
+{ TCEFLinkedWinControlBase }
+
+{$IFDEF FPC}
+
+procedure TCEFLinkedWinControlBase.SetVisible(Value: Boolean);
+{$IFDEF LINUX}
+var
+ TempChanged : boolean;
+{$ENDIF}
+begin
+ {$IFDEF LINUX}
+ TempChanged := (Visible <> Value);
+ {$ENDIF}
+
+ inherited SetVisible(Value);
+
+ {$IFDEF LINUX}
+ if not(csDesigning in ComponentState) and
+ TempChanged and
+ (Chromium <> nil) and
+ Chromium.Initialized then
+ Chromium.UpdateXWindowVisibility(Visible);
+ {$ENDIF}
+end;
+{$ENDIF}
+
+function TCEFLinkedWinControlBase.GetChildWindowHandle: THandle;
+begin
+ Result := 0;
+
+ if (Chromium <> nil) then Result := Chromium.WindowHandle;
+
+ if (Result = 0) then Result := inherited GetChildWindowHandle;
+end;
+
+procedure TCEFLinkedWinControlBase.UpdateSize;
+begin
+ {$IFDEF LINUX}
+ if not(csDesigning in ComponentState) and
+ (Chromium <> nil) and
+ Chromium.Initialized then
+ Chromium.UpdateBrowserSize(Left, Top, Width, Height);
+ {$ELSE}
+ inherited UpdateSize;
+ {$ENDIF}
+end;
+
+
+end.
+
diff --git a/source/uCEFChromiumWindow.pas b/source/uCEFChromiumWindow.pas
index abe99364..120003c5 100644
--- a/source/uCEFChromiumWindow.pas
+++ b/source/uCEFChromiumWindow.pas
@@ -59,11 +59,15 @@ uses
Messages,
{$ENDIF}
{$ENDIF}
- uCEFWindowParent, uCEFChromium, uCEFInterfaces, uCEFConstants, uCEFTypes, uCEFWinControl;
+ uCEFWindowParent, uCEFChromium, uCEFInterfaces, uCEFConstants, uCEFTypes,
+ uCEFWinControl, uCEFLinkedWinControlBase;
type
{$IFNDEF FPC}{$IFDEF DELPHI16_UP}[ComponentPlatformsAttribute(pidWin32 or pidWin64)]{$ENDIF}{$ENDIF}
- TChromiumWindow = class(TCEFWinControl)
+
+ { TChromiumWindow }
+
+ TChromiumWindow = class(TCEFLinkedWinControlBase)
protected
FChromium : TChromium;
FOnClose : TNotifyEvent;
@@ -71,11 +75,8 @@ type
FOnAfterCreated : TNotifyEvent;
FUseSetFocus : boolean;
- {$IFDEF FPC}
- procedure SetVisible(Value: Boolean); override;
- {$ENDIF}
- function GetBrowserInitialized : boolean;
- function GetChildWindowHandle : {$IFNDEF MSWINDOWS}{$IFDEF FPC}LclType.{$ENDIF}{$ENDIF}THandle; override;
+ function GetChromium: TChromium; override;
+ function GetBrowserInitialized : boolean;
{$IFDEF MSWINDOWS}
procedure WndProc(var aMessage: TMessage); override;
@@ -101,9 +102,8 @@ type
procedure CloseBrowser(aForceClose : boolean);
procedure LoadURL(const aURL : ustring);
procedure NotifyMoveOrResizeStarted;
- procedure UpdateSize; override;
- property ChromiumBrowser : TChromium read FChromium;
+ property ChromiumBrowser : TChromium read GetChromium;
property Initialized : boolean read GetBrowserInitialized;
published
@@ -186,15 +186,6 @@ begin
end;
end;
-function TChromiumWindow.GetChildWindowHandle : {$IFNDEF MSWINDOWS}{$IFDEF FPC}LclType.{$ENDIF}{$ENDIF}THandle;
-begin
- Result := 0;
-
- if (FChromium <> nil) then Result := FChromium.WindowHandle;
-
- if (Result = 0) then Result := inherited GetChildWindowHandle;
-end;
-
{$IFDEF MSWINDOWS}
procedure TChromiumWindow.WndProc(var aMessage: TMessage);
var
@@ -326,39 +317,9 @@ begin
if (FChromium <> nil) then FChromium.NotifyMoveOrResizeStarted;
end;
-{$IFDEF FPC}
-procedure TChromiumWindow.SetVisible(Value: Boolean);
-{$IFDEF LINUX}
-var
- TempChanged : boolean;
-{$ENDIF}
+function TChromiumWindow.GetChromium: TChromium;
begin
- {$IFDEF LINUX}
- TempChanged := (Visible <> Value);
- {$ENDIF}
-
- inherited SetVisible(Value);
-
- {$IFDEF LINUX}
- if not(csDesigning in ComponentState) and
- TempChanged and
- (FChromium <> nil) and
- FChromium.Initialized then
- FChromium.UpdateXWindowVisibility(Visible);
- {$ENDIF}
-end;
-{$ENDIF}
-
-procedure TChromiumWindow.UpdateSize;
-begin
- {$IFDEF LINUX}
- if not(csDesigning in ComponentState) and
- (FChromium <> nil) and
- FChromium.Initialized then
- FChromium.UpdateBrowserSize(Left, Top, Width, Height);
- {$ELSE}
- inherited UpdateSize;
- {$ENDIF}
+ result := FChromium;
end;
diff --git a/source/uCEFLinkedWindowParent.pas b/source/uCEFLinkedWindowParent.pas
index 0543523f..8c59a7f8 100644
--- a/source/uCEFLinkedWindowParent.pas
+++ b/source/uCEFLinkedWindowParent.pas
@@ -60,20 +60,21 @@ uses
Messages,
{$ENDIF}
{$ENDIF}
- uCEFWinControl, uCEFTypes, uCEFInterfaces, uCEFChromium;
+ uCEFWinControl, uCEFTypes, uCEFInterfaces, uCEFChromium,
+ uCEFLinkedWinControlBase;
type
{$IFNDEF FPC}{$IFDEF DELPHI16_UP}[ComponentPlatformsAttribute(pidWin32 or pidWin64)]{$ENDIF}{$ENDIF}
- TCEFLinkedWindowParent = class(TCEFWinControl)
+
+ { TCEFLinkedWindowParent }
+
+ TCEFLinkedWindowParent = class(TCEFLinkedWinControlBase)
protected
FChromium : TChromium;
- {$IFDEF FPC}
- procedure SetVisible(Value: Boolean); override;
- {$ENDIF}
+ function GetChromium: TChromium; override;
procedure SetChromium(aValue : TChromium);
- function GetChildWindowHandle : {$IFNDEF MSWINDOWS}{$IFDEF FPC}LclType.{$ENDIF}{$ENDIF}THandle; override;
{$IFDEF MSWINDOWS}
procedure WndProc(var aMessage: TMessage); override;
{$ENDIF}
@@ -81,10 +82,9 @@ type
public
constructor Create(AOwner : TComponent); override;
- procedure UpdateSize; override;
published
- property Chromium : TChromium read FChromium write SetChromium;
+ property Chromium : TChromium read FChromium write SetChromium;
end;
@@ -105,15 +105,6 @@ begin
FChromium := nil;
end;
-function TCEFLinkedWindowParent.GetChildWindowHandle : {$IFNDEF MSWINDOWS}{$IFDEF FPC}LclType.{$ENDIF}{$ENDIF}THandle;
-begin
- Result := 0;
-
- if (FChromium <> nil) then Result := FChromium.WindowHandle;
-
- if (Result = 0) then Result := inherited GetChildWindowHandle;
-end;
-
{$IFDEF MSWINDOWS}
procedure TCEFLinkedWindowParent.WndProc(var aMessage: TMessage);
var
@@ -156,39 +147,9 @@ begin
if (Operation = opRemove) and (AComponent = FChromium) then FChromium := nil;
end;
-{$IFDEF FPC}
-procedure TCEFLinkedWindowParent.SetVisible(Value: Boolean);
-{$IFDEF LINUX}
-var
- TempChanged : boolean;
-{$ENDIF}
+function TCEFLinkedWindowParent.GetChromium: TChromium;
begin
- {$IFDEF LINUX}
- TempChanged := (Visible <> Value);
- {$ENDIF}
-
- inherited SetVisible(Value);
-
- {$IFDEF LINUX}
- if not(csDesigning in ComponentState) and
- TempChanged and
- (FChromium <> nil) and
- FChromium.Initialized then
- FChromium.UpdateXWindowVisibility(Visible);
- {$ENDIF}
-end;
-{$ENDIF}
-
-procedure TCEFLinkedWindowParent.UpdateSize;
-begin
- {$IFDEF LINUX}
- if not(csDesigning in ComponentState) and
- (FChromium <> nil) and
- FChromium.Initialized then
- FChromium.UpdateBrowserSize(Left, Top, Width, Height);
- {$ELSE}
- inherited UpdateSize;
- {$ENDIF}
+ Result := FChromium;
end;
procedure TCEFLinkedWindowParent.SetChromium(aValue : TChromium);