C
cactus123456
Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,ShDocVw,mshtml;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
webbrowser:Twebbrowser;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
Form :IHTMLFormElement ;
Doc :IHTMLDocument2 ;
begin
if not webbrowser.Busy then
begin
Doc := WebBrowser.Document as IHTMLDocument2;
//doc不为空,但是form为空,为什么?
//如果不是动态创建就没有问题!
Form := Doc.Forms.item(1,0) as IHTMLFormElement;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
webbrowser:=twebbrowser.Create(self);
webbrowser.Navigate('http://www.263.net');
end;
end.
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,ShDocVw,mshtml;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
webbrowser:Twebbrowser;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
Form :IHTMLFormElement ;
Doc :IHTMLDocument2 ;
begin
if not webbrowser.Busy then
begin
Doc := WebBrowser.Document as IHTMLDocument2;
//doc不为空,但是form为空,为什么?
//如果不是动态创建就没有问题!
Form := Doc.Forms.item(1,0) as IHTMLFormElement;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
webbrowser:=twebbrowser.Create(self);
webbrowser.Navigate('http://www.263.net');
end;
end.