R
R
Romanson2016-08-16 13:41:42
Delphi
Romanson, 2016-08-16 13:41:42

How to assign a procedure to a dynamically created TChromium object in Delphi?

Hail the Lord! I'm trying to figure out why the OnBeforePopup procedure for a dynamically created Tchromium object is not assigned Compile
error:
[dcc32 Error] Unit6.pas(117): E2009 Incompatible types: 'method pointer and regular procedure' procedure
code

procedure OnBeforePopup(Sender: TObject; const browser: ICefBrowser;
const frame: ICefFrame; const targetUrl, targetFrameName: ustring;
targetDisposition: TCefWindowOpenDisposition; userGesture: Boolean;
var popupFeatures: TCefPopupFeatures; var windowInfo: TCefWindowInfo;
var client: ICefClient; var settings: TCefBrowserSettings;
var noJavascriptAccess: Boolean; out Result: Boolean);
var
web: TChromium;
begin
// prevent popup
web.Load(targetUrl);
Result := True;
end;

How do I create an object and call a procedure:
procedure TForm6.ChromeTabs1ButtonAddClick(Sender: TObject;
var Handled: Boolean);
var
T: TTabSheet;
web: TChromium;
begin
PageControl1.ActivePageIndex := ChromeTabs1.ActiveTabIndex;
T := TTabSheet.Create(self);
T.PageControl := PageControl1;
T.Caption := 'General';
PageControl1.ActivePage := T;
// t.TabVisible:=false;
web := TChromium.Create(T);
web := TChromium.Create(self);
web.OnBeforePopup := OnBeforePopup;
TWinControl(web).Name := 'NewWebBrowser' + inttostr(random(999666111));
TWinControl(web).Parent := T;
web.Align := alClient;
web.Load('ya.ru');
web.OnBeforePopup := OnBeforePopup;
end;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kalapanga, 2016-08-16
@Romanson

Declare OnBeforePopup as a method of some class, apparently TForm6 is the most it

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question