请大高手:创建IE导航到要的网页,如何得知网页装载完成?(msdn是针对浏览器控件的说明)

j19169123 2011-01-05 09:58:02
创建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();
}

...全文
29 点赞 收藏 2
写回复
2 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
小楫轻舟 2011-01-05
就是OnDocumentComplete了,
你可以数下触发几次了,一般是多次,
因为是按触发OnDocumentComplete事件的框架frames数来算的
最后一次触发后认为是网页都加载完也
具体可看下我的一篇blog
http://blog.csdn.net/LightBoat09/archive/2010/05/18/5604635.aspx
回复
healer_kx 2011-01-05
可以关注一下onload事件了。
回复
相关推荐
发帖
C++ 语言
创建于2007-09-28

6.0w+

社区成员

C++ 语言相关问题讨论,技术干货分享,前沿动态等
申请成为版主
帖子事件
创建了帖子
2011-01-05 09:58
社区公告
暂无公告