在头文件中加入:
void NewWindow3( IDispatch **ppDisp, VARIANT_BOOL *Cancel, DWORD dwFlags, BSTR bstrUrlContext, BSTR bstrUrl ); DECLARE_EVENTSINK_MAP()
首先在CPP文件中加入
#include <exdisp.h> //For IWebBrowser2* and others #include <exdispid.h> #include <Mshtml.h> #include <Mshtmdid.h> #include <shobjidl.h> BEGIN_EVENTSINK_MAP(CLhpHtmlView, CHtmlView) ON_EVENT(CLhpHtmlView, AFX_IDW_PANE_FIRST,273,NewWindow3,VTS_PDISPATCH VTS_PBOOL VTS_I4 VTS_BSTR VTS_BSTR) END_EVENTSINK_MAP()
实现:
void CLhpHtmlView::NewWindow3( IDispatch **ppDisp, VARIANT_BOOL *Cancel, DWORD dwFlags, BSTR bstrUrlContext, BSTR bstrUrl ) { *Cancel = TRUE; Navigate2( (LPCTSTR)bstrUrl , NULL , NULL ); return; }