对于一些含有多层框架的网页, 为什么不能获得pHTMLFrameBase2指针呢?CComBSTR tagName;
CComBSTR title;pDoc2->Release();
pDoc2 = NULL;
pElement->get_tagName(&tagName);if (!strcmpi((LPSTR)(_bstr_t)tagName, "FRAME") || !strcmpi((LPSTR)(_bstr_t)tagName, "IFRAME"))
{
CComPtr<IHTMLWindow2> pHTMLWindow;
CComPtr<IHTMLFrameBase2> pHTMLFrameBase2;
//执行到这里不能获得pHTMLFrameBase2, 返回FAILED
if(SUCCEEDED(pElement->QueryInterface(IID_IHTMLFrameBase2, (void**)&pHTMLFrameBase2)))
{
pElement->Release();
pElement = 0;
if(FAILED(pHTMLFrameBase2->get_contentWindow(&pHTMLWindow))
|| FAILED(pHTMLWindow->get_document(&pDoc2)))
break;
}
//d_printf("can not get iid_ihtmlframebase2");
}
else
{
break;
}
解决问题立即送分!
CComBSTR title;pDoc2->Release();
pDoc2 = NULL;
pElement->get_tagName(&tagName);if (!strcmpi((LPSTR)(_bstr_t)tagName, "FRAME") || !strcmpi((LPSTR)(_bstr_t)tagName, "IFRAME"))
{
CComPtr<IHTMLWindow2> pHTMLWindow;
CComPtr<IHTMLFrameBase2> pHTMLFrameBase2;
//执行到这里不能获得pHTMLFrameBase2, 返回FAILED
if(SUCCEEDED(pElement->QueryInterface(IID_IHTMLFrameBase2, (void**)&pHTMLFrameBase2)))
{
pElement->Release();
pElement = 0;
if(FAILED(pHTMLFrameBase2->get_contentWindow(&pHTMLWindow))
|| FAILED(pHTMLWindow->get_document(&pDoc2)))
break;
}
//d_printf("can not get iid_ihtmlframebase2");
}
else
{
break;
}
解决问题立即送分!
getframes->IHTMLFramesCollection2->item()->IHTMLWindow2->IHTMLDocument2
查询框架对象的IWebBrowser2接口,再获得窗口接口看看
如何查询框架对象的IWebBrowser2接口呢?
A.htm ----------------------
<frameset>..
<frame>1.htm...
<frame>2.htm...
<frameset>
<frame>3.htm
<frame>4.htm3.htm ----------------------
<frame> M
<frame> N我想取得frameN的指针.
可是pElement->QueryInterface(IID_IHTMLFrameBase2, (void**)&pHTMLFrameBase2)))执行失败.
还请大侠指点!