|
在View类里面重写了OnNewWindow2,让浏览器点击一些连接不会弹出IE而是在原本的窗口显示。但是遇到一些搜索栏还是会弹出IE,比如在本网站的搜索框输入内容后点击搜索会弹出IE,但是在百度搜索却不会。有没有哪位老师知道原因?
- void CRDPServerView::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);
- }
复制代码 |
上一篇: VS设置问题下一篇: 绘图闪烁,DuobleBuffered无效
|