以下代码给了我几个错误,其中两个是:
- [错误] Unit1.pas(28):未声明的标识符:'WebBrowser1NavigateComplete2'
- [错误] Unit1.pas(34):未声明的标识符:'WebBrowser1DocumentComplete'
我想知道它们是否没有在“使用”部分中声明。有谁知道为什么它不会编译。我从 Delphi Help 获得了代码。
也不会出现“消息框”或完成的“哔”声。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls, SHDocVw, StdCtrls, MSHTML, activex;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
WebBrowser1: TWebBrowser;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
CurDispatch: IDispatch; {save the interface globally }
implementation
{$R *.dfm}
procedure TForm1.WebBrowser1NavigateComplete2(Sender: TObject; const pDisp: IDispatch; var URL: OleVariant);
begin
if CurDispatch = nil then
CurDispatch := pDisp; { save for comparison }
end;
procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject; const pDisp: IDispatch; var URL: OleVariant);
begin
if (pDisp = CurDispatch) then
begin
Beep; {the document is loaded, not just a frame }
showmessage('download complete');
CurDispatch := nil; {clear the global variable }
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
WebBrowser1.Navigate('www.google.com');
end;
end.