正确的方法去拦截OnNewWindow2实现在同一个窗口显示_target的网页
2016-03-10 20:37
489 查看
// CMy5View message handlers #include <atlbase.h> #include <Mshtml.h> #include <COMDEF.H> void CMy5View::OnNewWindow2(LPDISPATCH* ppDisp, BOOL* Cancel) { // TODO: Add your specialized code here and/or call the base class CComPtr<IHTMLDocument2> pHTMLDocument2; m_pBrowserApp->get_Document((IDispatch **)&pHTMLDocument2); if (pHTMLDocument2!=NULL) { CComPtr<IHTMLElement> pIHTMLElement; pHTMLDocument2->get_activeElement(&pIHTMLElement); if (pIHTMLElement!=NULL) { variant_t url; HRESULT hr=pIHTMLElement->getAttribute(L"href", 0, &url); if (SUCCEEDED(hr)) { hr=m_pBrowserApp->Navigate2(&url, NULL, NULL, NULL, NULL); url.Clear(); if (SUCCEEDED(hr)) { *Cancel=TRUE; } } } } // CHtmlView::OnNewWindow2(ppDisp, Cancel); }
相关文章推荐
- ORACLE百例试炼四
- 带导航点的ViewPager
- matlab 编译c文件
- Struts2框架的标签库
- java批量下载文件
- windows下搭建绿色nodejs运行环境
- linux 几种清理系统中垃圾的方式
- 看博客,写博客
- java.lang.UnsupportedClassVersionError: org/apache/solr/common/params/SolrParams : Unsupported major
- MAC下安装NDKR10e
- MAC下安装NDKR10e
- vivado hls fft设计
- CocoaPods安装过程
- ubuntu 修改root密码
- 哪两个数据结构,同时具有较高的查找和删除性能
- ORACLE百例试炼三
- Android 开发百度地图之三GEO
- 丑数
- 更轻量的 View Controllers
- Java程序设计概述及环境(Java核心技术卷Ⅰ)