一个基类是CHtmlView的多文档应用程序,在新窗口打开网页时总是用ie打开的,如何新建一个文档/视图打开链接,即在新的mdi子窗口中打开链接?

解决方案 »

  1.   


    void CHtmlCtrl::OnNewWindow2(LPDISPATCH* ppDisp, BOOL* Cancel)
    {
        CHtmlNewWndWatch *        pWatch;    if(m_bNewWindow)
            return;    pWatch = CHtmlNewWndWatch::CreateNewWatch(this);    pWatch->SetRegisterAsBrowser(FALSE);
        *ppDisp = pWatch->GetApplication();    return;
    }CHtmlNewWndWatch *    CHtmlNewWndWatch::CreateNewWatch(CHtmlCtrl *pParent)
    {
        if(s_pOnceInstance == NULL)
        {
            s_pOnceInstance = new CHtmlNewWndWatch(pParent);
            s_pOnceInstance->Create(NULL,
                NULL,
                (WS_CHILD | WS_VISIBLE ),
                CRect(0, 0, 0, 0),
                pParent->GetParent(),
                0,
                NULL);        atexIT(DeleteWatch);
        }    return s_pOnceInstance;
    }void CHtmlNewWndWatch::OnBeforeNavigate2(LPCTSTR lpszURL,
                                             DWORD nFlags,
                                             LPCTSTR lpszTargetFrameName,
                                             CByteArray& baPostedData,
                                             LPCTSTR lpszHeaders,
                                             BOOL* pbCancel)
    {
        if(m_pHtmlCtrl)
            m_pHTMLCtrl->OnWatchNewWind(lpszURL);
        *PBCancel = TRUE;
        return;
    }