TChromium 在删除并再次创建组件后无法正常工作

TChromium not working after delete and create component again

这是我的代码:

主页按钮:

LimparComponentes(Self);
CriarTela(Janela, Self, Self.DsnStage);

LimparComponentes 程序:

var
myListWeb: TList;

myListWeb := TList.Create;

for i := 0 to Form.ComponentCount - 1 do
begin
  if (Form.Components[i].ClassType = TNeocWebBrowser) then
    begin
      if ParentIsStage(TNeocWebBrowser(Form.Components[i])) then
      begin
        myListWeb.Add(Form.Components[i]);
      end;
    end
end;

for i := 0 to (MyListWeb.Count - 1) do
  begin
    obj := myListWeb.items[i];
    FreeAndNil(obj);
  end;
  myListWeb.Clear;

CriarTela 程序:

for j := 0 to TelaC.ListaWebs.Count - 1 do
    begin
      complist.Add(CreateWeb(TelaC.ListaWebs.getWeb(j), Form, carroussel));
    end;

CreateWeb 函数

function CreateWeb(obj: TWeb; Form: TForm; AParent: TWinControl): pointer;
begin
  if Form.ClassType = TFormSimulando then
    result := CreateWebReal(obj, form, aparent, TNeocWebBrowser.Create(Form))
  else
    result := CreateWebFake(obj, form, aparent,
      TNeoWebBrowserPanel.Create(form));
end;

CreateWebReal 函数:

function CreateWebReal(obj: TWeb; Form: TForm; AParent: TWinControl; ref:
  pointer): TNeocWebBrowser;
var
  comp: TComponent;
  NewName: string;
  _nmesas: integer;
  tempURL: string;
begin
  _nmesas := obj.Indice;
  NewName := 'Web_' + IntToStr(_nmesas);
  comp := form.FindComponent(NewName);
  while Assigned(comp) do
  begin
    _nmesas := _nmesas + 1;
    NewName := 'Web_' + IntToStr(_nmesas);
    comp := form.FindComponent(NewName);
  end;

  if not Assigned(ref) then
    Result := TNeocWebBrowser.Create(Form)
  else
    Result := TNeocWebBrowser(ref);

  with Result do
  begin
    //ParentWindow := AParent.Handle;
    TWinControl(Result).Parent := AParent;
    CName := NewName;
    obj.Nome := newName;
    ShowHint := Form.ClassType <> TFormSimulando; //true;
    Hint := 'Web: ' + NewName;
    CHandle := obj.chandle;
    Seed := obj.semente;
    SeedJanela := obj.sementejanela;
    objBotaoEstrutura := obj;

    //    PopupMenu := getPopupMenu(form);

    Left := ZoomInteger(obj.esquerda);
    Top := ZoomInteger(obj.topo);
    Width := ZoomInteger(obj.largura);
    Height := ZoomInteger(obj.altura);
    Endereco := obj.Endereco;

    if Form.ClassType = TFormSimulando then
    begin
      //      Result.Navigate(Endereco);

      if Assigned(Result.Browser) then
        if ASsigned(Result.Browser.GetMainFrame) then
          Result.Browser.GetMainFrame.LoadUrl(Endereco);

    end;

    Repaint;
  end;
end;

TNeocWebBrowser 组件:

unit NeocWebBrowser;

interface

uses
  SysUtils, Classes, Controls, cefvcl, ceflib,
  SimpleTimer, Graphics;

type
  TNeocWebBrowser = class(TChromium)
  private
    FEndereco: String;
    FName: string;
  protected
  public
    Seed: Integer;
    SeedJanela: Integer;
    CHandle: Integer;
    objBotaoEstrutura: Pointer;
    constructor Create(AOwner: TComponent); override;
    destructor Destroy(); override;
  published
    property Endereco: string read FEndereco write FEndereco;
    property CName: string read fname write fname;
    property OnClick;
    property OnMouseUp;
    property OnMouseDown;
    property OnMouseMove;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Neocontrol', [TNeocWebBrowser]);
end;

constructor TNeocWebBrowser.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  Parent := TWinControl(AOwner);
  Height := 30;
  Width := 30;
  Visible := True;
end;

destructor TNeocWebBrowser.Destroy;
begin

  inherited;
end;

end.

基本上我的问题是:我可以打开 TNeocWebBrowser 一次,但是当我点击主页按钮或任何我改变屏幕并返回到上一个屏幕的按钮时,TNeocWebBrowser 不是显示了。我需要关闭此表单并再次打开以查看 TNeocWebBrowser。请下载视频以更好地了解我的问题。

Video explanation about the problem

非常感谢!

我更改此行:

if Assigned(Result.Browser) then
        if ASsigned(Result.Browser.GetMainFrame) then
          Result.Browser.GetMainFrame.LoadUrl(Endereco);

用于:

Result.Load(Endereco);

它工作正常。