CComPtr<IHTMLDocument3> pDoc3;
hr = pDoc2->QueryInterface(IID_IHTMLDocument3,(void**)&pDoc3) ;
if(hr==S_OK)
{
CComBSTR bstrName("INPUT");
CComPtr<IHTMLElementCollection> pElemCollINPUT;
hr=pDoc3->getElementsByTagName(bstrName,&pElemCollFrame);
if (hr==S_OK)
{
long pLength;
hr=pElemCollINPUT->get_length(&pLength);
if(hr==S_OK)
{
for(int i=0;i<pLength;i++)
{
IDispatch *pDispInputText=NULL;
CComVariant vIndex=i;
hr=pElemCollINPUT->item(vIndex,vIndex,&pDispInputText);
if(hr==S_OK)
{
CComPtr<IHTMLInputTextElement> pElemInputText;
hr=pDispFrame->QueryInterface(IID_IHTMLInputTextElement,(void**)&pElemInputText);
if(hr==S_OK)
{
}
}
pDispInputText->Release();
}
}
}
}
hr = pDoc2->QueryInterface(IID_IHTMLDocument3,(void**)&pDoc3) ;
if(hr==S_OK)
{
CComBSTR bstrName("INPUT");
CComPtr<IHTMLElementCollection> pElemCollINPUT;
hr=pDoc3->getElementsByTagName(bstrName,&pElemCollFrame);
if (hr==S_OK)
{
long pLength;
hr=pElemCollINPUT->get_length(&pLength);
if(hr==S_OK)
{
for(int i=0;i<pLength;i++)
{
IDispatch *pDispInputText=NULL;
CComVariant vIndex=i;
hr=pElemCollINPUT->item(vIndex,vIndex,&pDispInputText);
if(hr==S_OK)
{
CComPtr<IHTMLInputTextElement> pElemInputText;
hr=pDispFrame->QueryInterface(IID_IHTMLInputTextElement,(void**)&pElemInputText);
if(hr==S_OK)
{
}
}
pDispInputText->Release();
}
}
}
}
解决方案 »
- 能不能自己构造msg利用sendmessage来给窗口过程发送wm_command消息?我是不是在意淫?
- ffmpeg移植问题,请vc高手赐教
- 请教:ADO连接方式,访问Access2000,Edit控件变量给_variant_t变量赋值错误
- 能不能在ListCtrl中进行查询?
- VC6.0中获取JPG或者BMP图片某一点的像素。
- dump()在mfc中干什么用地?
- 写MFC时,为什么CMainFrame不能响应WM_KEYDOWN消息?
- Changing the color of radio buttons and checkboxes
- 内存泄漏
- 小小的问题,(设备环境的困惑)
- 哪位能说一下如何创建一个CEdit控件数组?
- SDI和MDI里,如何为视图添加滚动条?
<TD class=title align=right>First name: </TD>
<TD><INPUT maxLength=31 size=15 name=firstName></TD></TR>
<TR>这实在让我无知的大脑绞尽脑汁了,请帮我看看,谢谢
觉得可以利用两个td元素属于同一个tr来提高效率。
==================================================================我确实是这么想的,可是老大说 TR TD 都不支持IHTMLInputTextElement,郁闷
在访问ID的循环中设置一个标志变量,找到对应TD就设置这个标志,在下一次循环中访问TD中的INPUT之后退出循环
============================================================蒋老大能稍微详细一点儿吗?我阅历太浅,看不懂啊,我按照自己的理解取第一个<TD>的innerText之后再get_id,可是get_id怎么不管用呢?得不到id啊??
HRESULT hr = pDoc2->QueryInterface(IID_IHTMLDocument3,(void**)&pDoc3) ;
if(hr==S_OK)
{
CComBSTR bstrName("TD");
CComPtr<IHTMLElementCollection> pElemCollTD;
hr=pDoc3->getElementsByTagName(bstrName,&pElemCollTD);
bool b=false;
if (hr==S_OK)
{
long pLength;
hr=pElemCollTD->get_length(&pLength);
if(hr==S_OK)
{
for(int i=0;i<pLength;i++)
{
CComPtr<IDispatch> pDispTD;
CComVariant vIndex=i;
if (i==1)
{
hr=pElemCollTD->item(vIndex,vIndex,&pDispTD);
if(hr==S_OK)
{
CComPtr<IHTMLElement> pElemTD;
hr=pDispTD->QueryInterface(IID_IHTMLElement,(void**)&pElemTD);
if(hr==S_OK)
{
if(b==false)
{
CComBSTR bstrTemp;
pElemTD->get_innerText(&bstrTemp);
if()//如果bstrTemp中含有“First name:”
{
b=true;
}
}
else
{
CComPtr<IHTMLElementCollection> pElemCollTD1;
hr=pElemTD->get_all((IDispatch**)&pElemCollTD1);
if (hr==S_OK)
{
CComPtr<IDispatch> pDispTD1;
CComVariant vI=0;
hr=pElemCollTD1->item(vI,vI,&pDispTD1);
if(hr==S_OK)
{
CComPtr<IHTMLInputTextElement> pElemInputText;
hr=pDispTD1->QueryInterface(IID_IHTMLInputTextElement,(void**)&pElemInputText);
if(hr==S_OK)
{
//Get IHTMLInputTextElement OK!
} } }
return ;//直接退出
}
}
}
}
}
}
}
}
是不是下标越界?
好像确实是,一直是0就没有问题了,估计是我改成For循环出的问题,谢谢,现在我又遇到一怪事:我自己写了段填表代码放在函数前端,lion_wing(凤之焚)大仙的填表代码放在我的代码后,两段代码的目的都是填表,然而奇怪的是:当把lion_wing(凤之焚)大仙的填表代码注释掉之后,我的代码不起任何作用,当撤销对lion_wing(凤之焚)大仙代码的注释后再编译,我的代码竟然可以很好的工作!?再注释掉lion_wing(凤之焚)大仙的填表代码之后我的填表代码又不工作了!!这...异灵事件?