How To Input Chromium Source HTML to Memo.text Delphi 7 ?!

5,258 views
Skip to first unread message

ALE ALE DOT COM

unread,
Dec 1, 2014, 11:46:17 AM12/1/14
to delphichrom...@googlegroups.com
hello .. i from indonesian and just start to use Chromium ..

i was success to show a HTML source display in Chromium browser .. but how i can show that html source in memo.text on delphi form ?!

i hope someone can help me .. my english is not so good .. i was read many topic but i cant really understand what they mean ,,

FigthingNinjaSucks

unread,
Dec 16, 2014, 1:24:24 AM12/16/14
to delphichrom...@googlegroups.com
The GUIClient demo has an example - look for crm.Browser.MainFrame.GetSourceProc(CallbackGetSource);. 

the callback can be a bit tricky depending on your situation. The GUIClient demo uses the MainForm variable to find back to who called it. This works alright as long as TMainForm only has a single instance. If you have multiple instances of TMainForm then you need to get a bit creative. Using "anonymous methods" is the easiest (i find) - but it's a delphi 2009+ feature and wont work in Delphi7:

procedure TFormBrowser.acShowHTMLExecute(Sender: TObject);
begin
  crm.Browser.MainFrame.GetSourceProc(

      procedure(const src : ustring)
      begin
        self.memo1.text := src;
      end

      );
end;


... second option would be to add the ICefStringVisitor interface to your Form class:

  TFormBrowser= class(TForm, ICefStringVisitor )
    pnMain: TPanel;
    ..
  private
    procedure Visit(const str: ustring);
    ...
  end;

and then call it with :

procedure TFormBrowser.acShowHTMLExecute(Sender: TObject);
begin
  crm.Browser.MainFrame.GetSource(self);
end;

procedure TFormBrowser.Visit(const str: ustring);
begin
  memo1.text := str;
end;




ALE ALE DOT COM

unread,
Dec 25, 2014, 3:20:46 AM12/25/14
to delphichrom...@googlegroups.com
thanks bro .. it works .. :D

Pedro Moreira

unread,
Dec 23, 2015, 12:58:12 PM12/23/15
to delphichromiumembedded
Hi,

I'm trying to do something similar, but i want to the callback function be on another class, is this possible ? Just like this code :

unit simple1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, cefvcl, ceflib;

type
  TForm1 = class(TForm)
    Chromium1: TChromium;
    procedure FormCreate(Sender: TObject);
    procedure Chromium1LoadEnd(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame;
      httpStatusCode: Integer);
  public
  mySource : string;
  procedure StringVisitor(const str: ustring);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Chromium1LoadEnd(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame;
  httpStatusCode: Integer);
begin
  Chromium1.Browser.MainFrame.GetSourceProc(StringVisitor);  // error on this line
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
chromium1.load('http://www.google.com');
end;

procedure TForm1.StringVisitor(const str: ustring);
begin
mySource := str;
end;

end.
Reply all
Reply to author
Forward
0 new messages