//---------------------------------------------------------------------------
void __fastcall TForm1::CppWebBrowser1DocumentComplete(TObject *Sender,
LPDISPATCH pDisp, TVariant *URL)
{
try{
{
AnsiString filename = "myformdata.ini";
IHTMLDocument2 * pDoc = NULL;
IHTMLElementCollection * pAllElem = NULL;
IHTMLElement *pElem = NULL;
IHTMLInputTextElement * pInput = NULL;
VARIANT name;
long p;
BSTR bstrSrc;
AnsiString rt, env;
char buf[2048];
name.vt = VT_I4;
IDispatch * WebDocument = static_cast<IDispatch *>(CppWebBrowser1->Document);
IHTMLDocument2 *HTMLDocument = static_cast<IHTMLDocument2 *>(WebDocument);
pDoc = HTMLDocument;
if(pDoc!=NULL)
{
IHTMLElement *pBodyElement;
pDoc->get_body( &pBodyElement);
AnsiString mtmp="<html><body><h1><font color=FF0000>Hello,world!</font></h1></body></html>";
AnsiString StrTemp;
pBodyElement->get_innerHTML(&bstrSrc);
pBodyElement->get_innerHTML(&bstrSrc);
StrTemp=AnsiString(bstrSrc);
AnsiString sNewStr;
//sNewStr = StringReplace(StrTemp,Label1->Caption,"\n",TReplaceFlags()<<rfReplaceAll<<rfIgnoreCase);
ListBox1->Items->Text=StrTemp; //保存网页
AnsiString fn,fs;
fn=StrTemp;
fs=Edit1->Text.Trim();
int sn;
sn=fn.AnsiPos(fs);
Panel2->Caption=AnsiString(sn);
if(sn>0)
{
Timer1->Enabled=false;
stopid=1;
}
}
else
{
}
}
}catch(...)
{
}
AnsiString tt,ts;
tt=AnsiString(CppWebBrowser1->LocationURL);
ts=AnsiString(*URL);
//ListBox2->Items->Add(tt+"//"+ts);
if(stopid!=1&&tt==ts) //网页加载完成
{
AnsiString tmp;
nn++;
tmp=Edit2->Text+AnsiString(nn)+"/";//int pf=4;
Panel1->Caption=tmp;
Sleep(1000);
CppWebBrowser1->Navigate(tmp.WideChar(dest,180),&TVariant(4));
}
}