if you use CplitterWnd,then you can get View point from Getpane,such as //得到右视图指针 CRightView* CMainFrame::GetRightPane() { CWnd* pWnd = wndSplitter.GetPane(0, 1); CRightView* pView = DYNAMIC_DOWNCAST(CRightView, pWnd); return pView; } //得到左视图指针 CLeftView* CMainFrame::GetLeftPane() { CWnd* pWnd = wndSplitter.GetPane(0, 0); CLeftView* pView = DYNAMIC_DOWNCAST(CLeftView, pWnd); return pView; } in your CXDoc; CMainFrame*pFrm=(CMainFrame*)AfxGetMainWnd(); CLeftView*pLeftView=(CLeftView*)pFrm->GetLeftPane();
CDocument::GetNextView
前提是view被调用过CDocument::AddView加入到了doc
的viewlist中,文档模板中的那个view是自动被加上的,
因此可以用以上方法取得
如果是splitwnd,可以用CSplitterWnd::GetPane 取得
//得到右视图指针
CRightView* CMainFrame::GetRightPane()
{
CWnd* pWnd = wndSplitter.GetPane(0, 1);
CRightView* pView = DYNAMIC_DOWNCAST(CRightView, pWnd);
return pView;
}
//得到左视图指针
CLeftView* CMainFrame::GetLeftPane()
{
CWnd* pWnd = wndSplitter.GetPane(0, 0);
CLeftView* pView = DYNAMIC_DOWNCAST(CLeftView, pWnd);
return pView;
}
in your CXDoc;
CMainFrame*pFrm=(CMainFrame*)AfxGetMainWnd();
CLeftView*pLeftView=(CLeftView*)pFrm->GetLeftPane();