描述:
我现在能够得到IHTMLElementCollection,查找EDIT,button都能够找到何操作,
但是现在我想访问页面中的图片,也就是采用IHTMLImgElement,但是我怎么能够得到
一个有效的IHTMLImgElement呢?
CComPtr<IDispatch>pDisp;
pobjAllElement->item(COleVariant(strName),COleVariant((long)0),&pDisp);
如上面所示,通过控件的名称,我能够得到有效的控件的指针,但是img里面没有name这个属性
我应该怎么办呢?
解决方案1:
else
AfxMessageBox("Img get error!");
这里去掉就可以
length 和 item
item的name可以上数字VT_I4,进行枚举
HRESULT item(
VARIANT name,
VARIANT index,
IDispatch **pdisp
);
Parameters
name
[in] VARIANT of type VT_I4 or VT_BSTR that specifies the object or collection to retrieve. If this parameter is an integer, it is the zero-based index of the object. If this parameter is a string, all objects with matching name or id properties are retrieved, and a collection is returned if more than one match is made.
index
[in] VARIANT of type VT_I4 that specifies the zero-based index of the object to retrieve when a collection is returned.
pdisp
[out, retval] Address of a pointer that receives an IDispatch interface for the object or collection if successful, or NULL otherwise.