2024-11-26 13:09:11
2024-11-26 18:00:23
1、首先在类视图中添加对应(****View)的OnNewWindow2的监听相应函数
2、代码如下(CQuanzai_browsers10View改为自己的View类)
void CQuanzai_browsers10View::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);
CQuanzai_browsers10View* pWBVw = (CQuanzai_browsers10View*)pNewFrame->GetActiveView();
ASSERT(pWBVw);
pWBVw->SetRegisterAsBrowser(TRUE);
*ppDisp = pWBVw-> GetApplication();
}