怎样在程序中等待一个activex控件结束后继续运行?(100分)

  • 主题发起人 主题发起人 myqq
  • 开始时间 开始时间
M

myqq

Unregistered / Unconfirmed
GUEST, unregistred user!
我用的是ie浏览器的控件.请问怎样等待htm文件载入后再运行getlinks过程?
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls, SHDocVw_TLB, StdCtrls, Menus, ExtCtrls;

type
TForm1 = class(TForm)
WebBrowser1: TWebBrowser;
Memo1: TMemo;
MainMenu1: TMainMenu;
N2: TMenuItem;
N4: TMenuItem;
N6: TMenuItem;
OpenDialog1: TOpenDialog;
SaveDialog1: TSaveDialog;
Memo2: TMemo;
GroupBox1: TGroupBox;
procedure WebBrowser1DocumentComplete(ASender: TObject;
const pDisp: IDispatch
var URL: OleVariant);
procedure send;
procedure getlinks(memo:tmemo);
procedure FormCreate(Sender: TObject);
procedure N4Click(Sender: TObject);
procedure N2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
about:string;
htmcomplete:boolean;
implementation

{$R *.dfm}


procedure TForm1.send;
var
i:integer;
t:OleVariant;
begin
t := WebBrowser1.Document;
for i := 0 to t.all.length - 1 do
begin
//找到文字栏替换文字
if t.all.item(i).tagName = 'TEXTAREA' then
begin
t.all.item(i).value:=memo1.Text;
end;
if t.all.item(i).tagname = 'INPUT' then
if t.all.item(i).name = 'momom' then
begin
t.all.item(i).click;
exit;
end;

end;
end;
procedure TForm1.getlinks(memo:tmemo);
var
i:integer;
t:OleVariant;
begin
if htmcomplete=false then sleep(10000)

t := WebBrowser1.Document;
for i := 0 to t.links.length - 1 do
begin
if pos('ProductID',t.links.item(i).href)>0 then
memo.Lines.Add(t.links.item(i).href);
end;
end;

procedure TForm1.WebBrowser1DocumentComplete(ASender: TObject;
const pDisp: IDispatch
var URL: OleVariant);
begin
htmcomplete:=true;
end;

procedure TForm1.FormCreate(Sender: TObject);

begin
about:=memo1.Text;
webbrowser1.Navigate('http://auctions.163.com/');
memo1.Clear;
memo1.Lines.Add('网易网络营销是帮助您在网易拍卖网上增加买主的强力工具,它能在易趣网上所有交易商品的留言栏内发布信息。相当与1000个打字人员为您打字,详情请到我的店铺查看');
getlinks(memo2);
end;

procedure TForm1.N4Click(Sender: TObject);
begin
showmessage(about);
end;

procedure TForm1.N2Click(Sender: TObject);
begin
if n2.Checked=true then
begin
n2.Caption:='发送';
n2.Checked:=false;
exit;
end;
n2.Checked:=true;
n2.Caption:='暂停';
webbrowser1.Navigate(memo2.lines[0]);
showmessage('d');


end;

end.
 
Twebbrowser好像有这个载入事件的吧~~~~~
 
Twebbrowser.OnDownloadComplete 或者
IF Not Twebbrowser.Busy
 
Twebbrowser.OnDownloadComplete 这个是事件
IF Not Twebbrowser.Busy 这个是状态
 
问得很专业啊,myqq.delphibbs.com是你的主页吗?不是真的吧?
 
后退
顶部