请大高手:创建IE导航到要的网页,如何得知网页装载完成?(msdn是针对浏览器控件的说明)
创建IE:
CoCreateInstance(CLSID_InternetExplorer, NULL, CLSCTX_SERVER, IID_IWebBrowser2, (LPVOID*)&pWebBrowser);
接着导航到要的网页:
pWebBrowser->Navigate2(&vaURL,COleVariant((long)0,VT_I4),COleVariant((LPCTSTR)NULL,VT_BSTR),COleSafeArray(),COleVariant((LPCTSTR)NULL,VT_BSTR));
如何得知网页装载完成?(但msdn是针对浏览器控件的说明,可我的没有用到浏览器控件,不知怎么办,请高手指点迷经??)msdn的说明如下:
1。Define the OnDocumentComplete method in the header file for you CView- derived class:
afx_msg void OnDocumentComplete(LPDISPATCH lpDisp,VARIANT FAR* URL);
2。Declare the event sink in the same header file:
DECLARE_EVENTSINK_MAP()
3。In the implementation file (.cpp) for your CView-derived class, implement the event sink map:
BEGIN_EVENTSINK_MAP(CYourView, CView)
ON_EVENT(CWBTstView, ID_WEB_BROWSE, 259 /* DocumentComplete */,
OnDocumentComplete, VTS_DISPATCH VTS_PVARIANT)
END_EVENTSINK_MAP()
4。Implement the OnDocumentComplete method:
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();
pUnk->Release();
}