The problem is, that you did not declare the methods.
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
WebBrowser1: TWebBrowser;
procedure Button1Click(Sender: TObject);
// missing declarations
procedure WebBrowser1NavigateComplete2(Sender: TObject; const pDisp: IDispatch; var URL: OleVariant);
procedure WebBrowser1DocumentComplete(Sender: TObject; const pDisp: IDispatch; var URL: OleVariant);
private
{ Private declarations }
public
{ Public declarations }
end;
Seems that you just copy'paste the methods from somewhere else :o)
Manual assign Event Handler
For testing purpose I have a simple form with a single TWebBrowser
component and I have written 2 methods WebBrowser1DocumentComplete
and HandmadeDocumentComplete
.
The form code look like this
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.OleCtrls, SHDocVw;
type
TForm1 = class( TForm )
WebBrowser1 : TWebBrowser;
procedure WebBrowser1DocumentComplete( ASender : TObject; const pDisp : IDispatch; const URL : OleVariant );
procedure HandmadeDocumentComplete( ASender : TObject; const pDisp : IDispatch; const URL : OleVariant );
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1 : TForm1;
implementation
{$R *.dfm}
procedure TForm1.HandmadeDocumentComplete( ASender : TObject; const pDisp : IDispatch; const URL : OleVariant );
begin
// Do something
end;
procedure TForm1.WebBrowser1DocumentComplete( ASender : TObject; const pDisp : IDispatch; const URL : OleVariant );
begin
// Do something
end;
end.
Now have a look at the ObjectInspector for WebBrowser1
Every published method that matches the event handler property will be shown inside the combo box and can be selected.
Or you can assign the method by code
procedure TForm1.FormCreate( Sender : TObject );
begin
// WebBrowser1.OnDocumentComplete := WebBrowser1DocumentComplete;
WebBrowser1.OnDocumentComplete := HandmadeDocumentComplete;
end;