3,056
社区成员
发帖
与我相关
我的任务
分享
//设置值
void CTestInputDlg::SetElementValue(CString tagName,CString strValue,IHTMLDocument2* pDoc)
{
IDispatch* pElemDisp = NULL;
IHTMLElement* pElem=NULL;
IHTMLElementCollection* pElemColl = NULL;
GetElementCollection(tagName,&pElemColl,pDoc); //获取指定TAG集合
if(pElemColl!=NULL)
{
long length;
pElemColl->get_length(&length); //指定TAG集合长度
for (long i=0;i<length;i++)
{
_variant_t varBase(0);
_variant_t varIndex(i);
HRESULT hr = pElemColl->item(varIndex, varBase, &pElemDisp);
if (SUCCEEDED(hr) && pElemDisp!=NULL)
{
hr = pElemDisp->QueryInterface(IID_IHTMLElement,(void**)&pElem);
if(SUCCEEDED(hr) && pElem!=NULL)
{
BSTR bstrTemp;
pElem->get_id(&bstrTemp);
//pElem->
CString tempStr(bstrTemp);
MessageBox(tempStr);
}
pElemDisp->Release();
}
}
}
}