我现在能够得到IHTMLElementCollection,查找EDIT,button都能够找到何操作,
但是现在我想访问页面中的图片,也就是采用IHTMLImgElement,但是我怎么能够得到
一个有效的IHTMLImgElement呢?
CComPtr<IDispatch>pDisp;
pobjAllElement->item(COleVariant(strName),COleVariant((long)0),&pDisp);
如上面所示,通过控件的名称,我能够得到有效的控件的指针,但是img里面没有name这个属性
我应该怎么办呢?
但是现在我想访问页面中的图片,也就是采用IHTMLImgElement,但是我怎么能够得到
一个有效的IHTMLImgElement呢?
CComPtr<IDispatch>pDisp;
pobjAllElement->item(COleVariant(strName),COleVariant((long)0),&pDisp);
如上面所示,通过控件的名称,我能够得到有效的控件的指针,但是img里面没有name这个属性
我应该怎么办呢?
解决方案 »
- socket.attach和套接字的拷贝的区别?
- debug没有问题,release没错误,但没效果。愣是发现不了问题,无奈求助大家啊
- 最近做个Smart Card Logon
- 关于VFP中保存图片的问题,高手请进~
- 工具条按钮的简单问题!在线等!
- 在线等!!!!!!!! ADO+SQL Server
- 不知道ie有没有提供相关的com接口,我想使用该接口来在我的程序中打开图片。因为我是在pda下开发,找不到一个有效的方式来显示gif图片。
- 探讨一下挂钩的问题(up有分)
- 使用CJLibrary时出现的lnk 2001的错误
- 请问怎样把 char 转换成 int ?
- 怎样用DirectDraw做出类似于WinMediaPlayer的界面
- 请问,想让一个函数返回一个数组要如何定义这个函数?
item的name可以上数字VT_I4,进行枚举
HRESULT item(
VARIANT name,
VARIANT index,
IDispatch **pdisp
);
Parametersname
[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.
或者说,我找到那个img后,如何得到他的url呢?
CComPtr<IDispatch> pDisp;
long l ;
CComBSTR bStr;
VARIANT id;
pobjAllElement->get_length(&l);
for (long i =0;i<l;i++)
{
V_VT(&id) = VT_I4;
V_I4(&id) = i;
pobjAllElement->item(id,COleVariant((long)0),&pDisp);
CComPtr<IHTMLImgElement> pElement;
if(SUCCEEDED(pDisp->QueryInterface(IID_IHTMLImgElement,(void**)&pElement)))
{
pElement->get_src(&bStr);
AfxMessageBox((CString)bStr);
}
else
AfxMessageBox("Img get error!");
}
AfxMessageBox("Img get error!");
这里去掉就可以
pobjAllElement->item(id,COleVariant((long)0),&pDisp);