- // 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);
- }
// 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);
}
找了一天了 整整找了4个半小时啊 终于被我找到解决方法了
就是VC6就可以解决了