0

I looked at two previous questions, viz. How to get elements by name in Delphi Chromium Embedded and Delphi Embedded Chrome. These questions and their answers are clear enough and easy to copy and paste, yet they do not work. The method visit() is never called.

Is this still the proper way to do this, or isn't it supposed to work in DCEF3? Or is it something else that can go awry here?

I am working with XE2 platform windows32.

unit Unit1;

interface

uses ceflib, cefvcl, Vcl.Forms, Vcl.StdCtrls, Vcl.ExtCtrls, Vcl.Controls,
  System.Classes;

type
  TForm1 = class(TForm)
    Chromium1: TChromium;
    Panel1: TPanel;
    Button1: TButton;
    procedure FormShow(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  public
  end;


type
    TElementNameVisitor = class(TCefDomVisitorOwn)
      private
        FName: string;
      protected
        procedure visit(const document: ICefDomDocument); override;
      public
        constructor Create(const AName: string); reintroduce;
      end;

var
  Form1: TForm1;


implementation

{$R *.dfm}

uses Dialogs;

constructor TElementNameVisitor.Create(const AName: string);
begin
    inherited Create;
    FName := AName;
end;



procedure TElementNameVisitor.visit(const document: ICefDomDocument);

  procedure ProcessNode(ANode: ICefDomNode);
  var Node: ICefDomNode;
  begin
        if Assigned(ANode) then
            begin
            Node := ANode.FirstChild;
            while Assigned(Node) do
                begin
                if Node.GetElementAttribute('name') = FName then
                    ShowMessage(Node.GetElementAttribute('value'));
                ProcessNode(Node);
                Node := Node.NextSibling;
                end {while}
            end {if};
  end;

begin
    ProcessNode(document.Body);
end;



procedure TForm1.Button1Click(Sender: TObject);
var visitor: TElementNameVisitor;
begin
    visitor := TElementNameVisitor.Create('EuroB');
    Chromium1.Browser.MainFrame.VisitDom(visitor);
end;



procedure TForm1.FormShow(Sender: TObject);
begin
   Chromium1.Load('D:\Projects\Chromium\test.html');
end;


end. 
Community
  • 1
  • 1
user508402
  • 480
  • 1
  • 4
  • 19

1 Answers1

0

There seems to be a version issue in DCEF3. I just got a fresh copy from http://delphichromiumembedded.googlecode.com/svn/trunk/ and now my code is called. I am not sure which are the relevant version numbers to report. For LibCef.dll:

new: libcef.dll has version 1.1364.1123.0

old: libcef.dll has version 3.2171.1979.0

Strange numbers but the dates show that the lower version nulber is a more recent compile.

user508402
  • 480
  • 1
  • 4
  • 19
  • This is increasingly becoming a monologue, but alright, someone else may come looking for a solution to the same problems... In the above, the version numbers are correct and he dates shown were those of my own file system. So the newer version seems to be defective. – user508402 Nov 03 '15 at 12:51