如何获取子框架IHTMLWindow2的指针
IHTMLFramesCollection2 *pFrames;
LPDISPATCH pDisp;
VARIANT id,index;
pDisp=mycwb->Document;
if(pDisp)
{
}
else
{
ShowMessage("Document read error.");
return;
}
if(SUCCEEDED(pDisp->QueryInterface(IID_IHTMLDocument2,(void **)&pHTMLDoc)))
{
}
else
{return;}
if(pHTMLDoc->get_forms(&pelement)!=S_OK) //得到form指针
{
pHTMLDoc->Release();
pDisp->Release();
pelement->Release();
ShowMessage("read form failed!");
return;
}
long p;
pelement->get_length(&p); //form的个数
ShowMessage(" Forms: "+IntToStr(p));
if(p>0)
{
for (long i=0;i<p;i++)
{
V_VT(&id)=VT_I4;
V_I4(&id)=i;
V_VT(&index)=VT_I4;
V_I4(&index)=0;
}
}
//如果forms是0,那么取Window2数
IHTMLWindow2 *pHTMLhwd;
long phwd;
if(pHTMLDoc->get_parentWindow(&pHTMLhwd)==S_OK)
ShowMessage("Get IHTMLWindow2 OK");
pHTMLhwd->get_length(&phwd);
ShowMessage("Total IHTMLWindow2 number:"+IntToStr(phwd));
//获取frames数成功
IHTMLFramesCollection2 *pFrames3;
if(pHTMLhwd->get_frames(&pFrames3)==S_OK)
{
pFrames3->get_length(&phwd);
ShowMessage("子框架:"+IntToStr(phwd));
}
//如果子框架数大于0,
//则一个一个地取得子框架的IHTMLWindow2指针
IHTMLWindow2 *pHTMLhwd1;
tagVARIANT id1;
if(phwd>0)
{
for(int a=0;a<phwd;a++)
{
。。。。。。
}
}
请那位大虾帮忙告诉我如何写。。。。。中的内容,就是取得子框架的指针
相关推荐
iframe读取document出现拒绝访问
iframe.document出现拒绝访问。 threw an exception of type 'System.UnauthorizedAccessException' dynamic {System.UnauthorizedAccessException}
Delphi自动提交网页表单和获取框架网页源码.doc
练习自动淘宝登录时收集的资料
webBrowser 禁用消息框alert 并且获得内容
webBrowser 禁用消息框 alert 并且获得内容。
VC6中用DOM遍历网页中的元素.pdf
VC6中用DOM遍历网页中的元素.pdf
winform执行javascrip源代码
string scriptline01 = @"function ShowPageInfo() {"; string scriptline02 = @" var numLinks = document.links.length; "; string scriptline03 = @" var numForms = document.forms.length; "; string scriptline04 = @" var numImages = document.images.length; "; string scriptline05 = @" var numScripts = document.scripts.length; "; string scriptline06 = @" alert(‘网页的统计结果:\r\n链接数:‘ + numLinks + "; string scriptline07 = @" ‘\r\n表单数:‘ + numForms + "; string scriptline08 = @" ‘\r\n图像数:‘ + numImages + "; string scriptline09 = @" ‘\r\n脚本数:‘ + numScripts);}"; string scriptline10 = @"ShowPageInfo();"; string strScript = scriptline01 + scriptline02 + scriptline03 + scriptline04 + scriptline05 + scriptline06 + scriptline07 + scriptline08 + scriptline09 + scriptline10; IHTMLWindow2 win = (IHTMLWindow2)webBrowser.Document.Window.DomWindow; win.execScript(strScript, "Javascript");


网络及通讯开发
