//-------------------------------Unit1.pas-------------------------------------
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleCtrls, SHDocVw;
type
TForm1 = class(TForm)
WebBrowser1: TWebBrowser;
Memo1: TMemo;
Button1: TButton;
Edit1: TEdit;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
procedure WebBrowser1DocumentComplete(Sender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
CompleteNum:integer;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
CompleteNum:=0;
WebBrowser1.Navigate(trim(Edit1.Text));
while WebBrowser1.ReadyState <READYSTATE_COMPLETE do Application.ProcessMessages;
Memo1.Lines.Add('我是1号,我通过判断WebBrowser1.ReadyState >READYSTATE_COMPLETE的结果向首长汇报,网页已经打开完毕,特此报告!')
end;
procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject;
const pDisp: IDispatch; var URL: OleVariant);
begin
Memo1.Lines.Add('CompleteNum: '+inttostr(CompleteNum));
Memo1.Lines.Add('我是2号,我通过WebBrowser1DocumentComplete事件向首长汇报,网页已经打开完毕,特此报告!')
if(pDisp=WebBrowser1.ControlInterface)then
begin
Memo1.Lines.Add('我是3号 我通过判断pDisp 网页已经打开完毕,特此报告!')
end;
end;
end.
//------------------------------Unit1.dfm--------------------------------------
object Form1: TForm1
Left = 181
Top = 84
Width = 790
Height = 633
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 16
Top = 496
Width = 65
Height = 13
Caption = #32593#22336#65306
end
object WebBrowser1: TWebBrowser
Left = 16
Top = 16
Width = 753
Height = 337
TabOrder = 0
OnDocumentComplete = WebBrowser1DocumentComplete
ControlData = {
4C000000D34D0000D42200000000000000000000000000000000000000000000
000000004C000000000000000000000001000000E0D057007335CF11AE690800
2B2E126208000000000000004C0000000114020000000000C000000000000046
8000000000000000000000000000000000000000000000000000000000000000
00000000000000000100000000000000000000000000000000000000}
end
object Memo1: TMemo
Left = 16
Top = 368
Width = 753
Height = 121
ScrollBars = ssBoth
TabOrder = 1
end
object Button1: TButton
Left = 288
Top = 536
Width = 233
Height = 33
Caption = #35266#30475#26159#21542#25171#24320#23436#27605
TabOrder = 2
OnClick = Button1Click
end
object Edit1: TEdit
Left = 88
Top = 496
Width = 681
Height = 21
TabOrder = 3
Text = 'http://www.delphibbs.com/delphibbs/listq.asp'
end
end
//------------------------Project1.dpr----------------------------------------
uses
Forms,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.