1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-11-23 21:34:53 +02:00

Fix TEmbeddedChromium as sub-component

This commit is contained in:
martin
2021-03-20 23:06:59 +01:00
parent df326d4e06
commit 74f4caf000
2 changed files with 10 additions and 2 deletions

View File

@@ -346,6 +346,8 @@ constructor TEmbeddedChromium.Create(AOwner: TComponent);
begin begin
FState := csNoBrowser; FState := csNoBrowser;
inherited Create(AOwner); inherited Create(AOwner);
SetSubComponent(True);
Name := 'Chromium';
end; end;
destructor TEmbeddedChromium.Destroy; destructor TEmbeddedChromium.Destroy;
@@ -464,6 +466,8 @@ end;
procedure TChromiumWrapper.MaybeDestroy; procedure TChromiumWrapper.MaybeDestroy;
begin begin
if FChromium.Owner <> nil then
FBrowserWindow.RemoveComponent(FChromium);
CloseBrowser(True); CloseBrowser(True);
FBrowserWindow := nil; FBrowserWindow := nil;
@@ -479,7 +483,7 @@ begin
FBrowserWindow := AOwner; FBrowserWindow := AOwner;
FWrapperState := wsNone; FWrapperState := wsNone;
FChromium := TEmbeddedChromium.Create(nil); FChromium := TEmbeddedChromium.Create(AOwner);
if not(csDesigning in AOwner.ComponentState) then if not(csDesigning in AOwner.ComponentState) then
begin begin
FChromium.OnClose := {$IFDEF FPC}@{$ENDIF}BrowserThread_OnClose; FChromium.OnClose := {$IFDEF FPC}@{$ENDIF}BrowserThread_OnClose;
@@ -692,10 +696,12 @@ constructor TBrowserWindow.Create(AOwner: TComponent);
begin begin
FChromiumWrapper := TChromiumWrapper.Create(Self); FChromiumWrapper := TChromiumWrapper.Create(Self);
inherited Create(AOwner); inherited Create(AOwner);
ControlStyle := ControlStyle + [csOwnedChildrenNotSelectable];
end; end;
destructor TBrowserWindow.Destroy; destructor TBrowserWindow.Destroy;
begin begin
RemoveComponent(FChromiumWrapper.FChromium);
inherited Destroy; inherited Destroy;
FChromiumWrapper.MaybeDestroy; FChromiumWrapper.MaybeDestroy;
Application.RemoveAsyncCalls(Self); Application.RemoveAsyncCalls(Self);
@@ -727,7 +733,7 @@ procedure Register;
begin begin
{$I res/TBrowserWindow.lrs} {$I res/TBrowserWindow.lrs}
RegisterComponents('Chromium', [TBrowserWindow]); RegisterComponents('Chromium', [TBrowserWindow]);
RegisterPropertyEditor(ClassTypeInfo(TEmbeddedChromium), nil,'',TClassPropertyEditor); RegisterClass(TEmbeddedChromium);
RegisterPropertyEditor(TypeInfo(TOnClose), TEmbeddedChromium, 'OnClose', THiddenPropertyEditor); RegisterPropertyEditor(TypeInfo(TOnClose), TEmbeddedChromium, 'OnClose', THiddenPropertyEditor);
end; end;
{$ENDIF} {$ENDIF}

View File

@@ -961,6 +961,7 @@ begin
FChromium.OnIMECompositionRangeChanged := @DoGetChromiumIMECompositionRangeChanged; FChromium.OnIMECompositionRangeChanged := @DoGetChromiumIMECompositionRangeChanged;
inherited Create(AOwner); inherited Create(AOwner);
ControlStyle := ControlStyle + [csOwnedChildrenNotSelectable];
CopyOriginalBuffer := true; CopyOriginalBuffer := true;
end; end;
@@ -1012,6 +1013,7 @@ procedure Register;
begin begin
{$I res/TOsrBrowserWindow.lrs} {$I res/TOsrBrowserWindow.lrs}
RegisterComponents('Chromium', [TOsrBrowserWindow]); RegisterComponents('Chromium', [TOsrBrowserWindow]);
RegisterClass(TEmbeddedOsrChromium);
RegisterPropertyEditor(TypeInfo(TOnClose), TEmbeddedOsrChromium,'OnClose',THiddenPropertyEditor); RegisterPropertyEditor(TypeInfo(TOnClose), TEmbeddedOsrChromium,'OnClose',THiddenPropertyEditor);
RegisterPropertyEditor(TypeInfo(TOnPaint), TEmbeddedOsrChromium,'OnPaint',THiddenPropertyEditor); RegisterPropertyEditor(TypeInfo(TOnPaint), TEmbeddedOsrChromium,'OnPaint',THiddenPropertyEditor);
RegisterPropertyEditor(TypeInfo(TOnGetViewRect), TEmbeddedOsrChromium,'OnGetViewRect',THiddenPropertyEditor); RegisterPropertyEditor(TypeInfo(TOnGetViewRect), TEmbeddedOsrChromium,'OnGetViewRect',THiddenPropertyEditor);