Page 1 of 1

OnProcessMessageReceived issue

Posted: Sat Nov 25, 2017 5:42 pm
by xpert13
Help me please with my problem.

I created simple program:
dpr file

Code: Select all

program Cef4Bug;

uses
  Forms,
  uCEFApplication,
  uCEFTypes,
  uCEFInterfaces,
  uCEFv8Value,
  uCEFConstants,
  Main in 'Main.pas' {Form1};

{$R *.res}

procedure OnRenderProcessMessageReceived(const pBrowser: ICefBrowser; uSourceProcess: TCefProcessId;
  const pMessage: ICefProcessMessage; var aHandled : boolean);
begin

end;

begin
  GlobalCEFApp := TCefApplication.Create;
  GlobalCEFApp.OnProcessMessageReceived := OnRenderProcessMessageReceived;

  if GlobalCEFApp.StartMainProcess then
  begin
    Application.Initialize;
    Application.MainFormOnTaskbar := True;
    Application.CreateForm(TForm1, Form1);
    Application.Run;
    Application.Run;
  end;

  GlobalCEFApp.Free;
end.
pas file

Code: Select all

unit Main;

interface

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

type
  TForm1 = class(TForm)
    procedure FormShow(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  Chromium1: TChromium;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chromium1 := TChromium.Create(Self);
  Chromium1.DefaultUrl := 'https://google.com/';
end;

procedure TForm1.FormShow(Sender: TObject);
begin
  Chromium1.CreateBrowser(Self);
end;

end.
When I execute the program the window is blank, but if I comment line

Code: Select all

GlobalCEFApp.OnProcessMessageReceived := OnRenderProcessMessageReceived;
- everything is fine and I see Google page.

I can't undestand where is my mistake. Your JSEval demo works perfect.

Re: OnProcessMessageReceived issue

Posted: Sat Nov 25, 2017 6:09 pm
by salvadordf
Hi,

I just uploaded a new update with a fix for that procedure. Please download CEF4Delphi again.

The problem in that function was the "aHandled" parameter. It wasn't initialized with False.

Re: OnProcessMessageReceived issue

Posted: Sat Nov 25, 2017 6:51 pm
by xpert13
Thank you, salvadordf