肾阴虚能喝什么茶:自编的CHtmlView浏览器,怎么截获超连接,不让新窗口在IE中打开? - VC/MFC...

来源:百度文库 编辑:偶看新闻 时间:2024/07/05 13:31:53
重载OnNewWindow2函数,把以下代码的CMfcieView换成你的htmlview类就可以了。
void   CMfcieView::OnNewWindow2(   LPDISPATCH*   ppDisp,   BOOL*   Cancel   )
{

        //   Get   a   pointer   to   the   application   object
        CWinApp*   pApp   =   AfxGetApp();

        //   Get   the   correct   document   template
        CDocTemplate*   pDocTemplate;
        POSITION   pos   =   pApp-> GetFirstDocTemplatePosition();
        pDocTemplate   =   pApp-> GetNextDocTemplate(pos);

        ASSERT(pDocTemplate);

        //   Create   the   new   frame
        CFrameWnd*   pNewFrame   =   pDocTemplate-> CreateNewFrame(GetDocument(),
                                                                      (CFrameWnd*)AfxGetMainWnd());
        ASSERT(pNewFrame);

        //   Activate   the   frame   and   set   its   active   view
        pDocTemplate-> InitialUpdateFrame(pNewFrame,   NULL);

        CMfcieView*   pWBVw   =   (CMfcieView*)pNewFrame-> GetActiveView();
        ASSERT(pWBVw);

        pWBVw-> SetRegisterAsBrowser(TRUE);

        *ppDisp   =   pWBVw-> GetApplication();

}       添加一个类如MyHtmlView,基予CHtmlView,再添加虚拟函数virtual   void   OnNewWindow2(   LPDISPATCH*   ppDisp,   BOOL*   Cancel   );或virtual   void   OnStatusTextChange(   LPCTSTR   lpszText   );
例:
void   MyHtmlView::OnStatusTextChange(   LPCTSTR   lpszText   )
{
        //处理lpszText,只纪录,http://,ftp://,mailto:等开头的字串;
        CHtmlView::OnStatusTextChange(   LPCTSTR   lpszText   );//处理原来的函数
}