主题:[讨论]对话框上用WebBrowser 控件,怎样判断网页已经下完?
在MSDN上看到下面的代码:
但是CWebBrowser2压根就没有OnDocumentComplete()这个方法,这是怎么弄的?
而且网上还有些说法认为,当网页里面有不止一个Frame时,OnDocumentComplete()函数会激发很多次,而你无从得知到底哪一个是所有页面完全下载完毕的。
这样的话,该咋整???
void CWBTstView::OnDocumentComplete(LPDISPATCH lpDisp,
VARIANT FAR* URL)
{
IUnknown* pUnk;
LPDISPATCH lpWBDisp;
HRESULT hr;
pUnk = m_webBrowser.GetControlUnknown();
ASSERT(pUnk);
hr = pUnk->QueryInterface(IID_IDispatch, (void**)&lpWBDisp);
ASSERT(SUCCEEDED(hr));
if (lpDisp == lpWBDisp )
{
// Top-level Window object, so document has been loaded
TRACE("Web document is finished downloading\n");
}
lpWBDisp->Release();
}
但是CWebBrowser2压根就没有OnDocumentComplete()这个方法,这是怎么弄的?
而且网上还有些说法认为,当网页里面有不止一个Frame时,OnDocumentComplete()函数会激发很多次,而你无从得知到底哪一个是所有页面完全下载完毕的。
这样的话,该咋整???
void CWBTstView::OnDocumentComplete(LPDISPATCH lpDisp,
VARIANT FAR* URL)
{
IUnknown* pUnk;
LPDISPATCH lpWBDisp;
HRESULT hr;
pUnk = m_webBrowser.GetControlUnknown();
ASSERT(pUnk);
hr = pUnk->QueryInterface(IID_IDispatch, (void**)&lpWBDisp);
ASSERT(SUCCEEDED(hr));
if (lpDisp == lpWBDisp )
{
// Top-level Window object, so document has been loaded
TRACE("Web document is finished downloading\n");
}
lpWBDisp->Release();
}