SDI或是MDI里的CHtmlView处理范例 void CYourView::OnNewWindow2(LPDISPATCH FAR* ppDisp, BOOL FAR* 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); CYourView* pWBVw = (CYourView*)pNewFrame->GetActiveView(); ASSERT(pWBVw); pWBVw->m_webBrowser.SetRegisterAsBrowser(TRUE); *ppDisp = pWBVw->m_webBrowser.GetApplication(); }
void CYourView::OnNewWindow2(LPDISPATCH FAR* ppDisp,BOOL FAR* Cancel) { 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*)GetParentFrame()); ASSERT(pNewFrame); // Activate the frame and set its active view pDocTemplate->InitialUpdateFrame(pNewFrame, NULL); CYourView* pWBVw = (CYourView*)pNewFrame->GetActiveView(); ASSERT(pWBVw); pWBVw->m_webBrowser.SetRegisterAsBrowser(TRUE); *ppDisp = pWBVw->m_webBrowser.GetApplication(); }
OnNewWindow()函数另外,CHtmlView 的话也可以: CHtmlView::OnNewWindow2(LPDISPATCH* ppDisp, BOOL* Cancel)
BOOL FAR* 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); CYourView* pWBVw = (CYourView*)pNewFrame->GetActiveView();
ASSERT(pWBVw); pWBVw->m_webBrowser.SetRegisterAsBrowser(TRUE); *ppDisp = pWBVw->m_webBrowser.GetApplication();
}
{ 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*)GetParentFrame());
ASSERT(pNewFrame); // Activate the frame and set its active view
pDocTemplate->InitialUpdateFrame(pNewFrame, NULL); CYourView* pWBVw = (CYourView*)pNewFrame->GetActiveView();
ASSERT(pWBVw); pWBVw->m_webBrowser.SetRegisterAsBrowser(TRUE); *ppDisp = pWBVw->m_webBrowser.GetApplication();
}