if your delet action ocuur in the document class , you may call CDocument::UpdateAllViews(); else your can call CView::GetDocument()->UpdateAllViews(NULL);for more information ,your call back on msdn.
到底怎么回事?CFrameWnd类中有一个GetActiveView()可以返回当前View的指针,我的CMainFrame继承自CFrameWnd,于是我在CMyDocument类中的一个函数里调用: UpDateAllViews((CMyView*)CMainFrame::GetActiveView()),可是编译出错: illegal call of non-static member function
you may call CDocument::UpdateAllViews();
else your can call
CView::GetDocument()->UpdateAllViews(NULL);for more information ,your call back on msdn.
UpDateAllViews((CMyView*)CMainFrame::GetActiveView()),可是编译出错:
illegal call of non-static member function
[1]在CMyDoc中加入成员变量CMyView* m_pView;
[2]在CMyView中重载GetDocument()函数 CMyDoc* CMyView::GetDocument(){return (CMyDoc*)GetDocument();}
[3]在CMView中响应OnCreate消息,加入GetDocument()->m_pView=this;ok,已后在MyView中用GetDocument()得到CMyDoc.在CMyDoc中通过m_pView访问CMyView.
用CDocument::GetFirstViewPos和CDocument::GetNextView可以枚举与该项doc关联的所有view.用下面的代码可以得到当前的active view:
CFrameWnd* pMainFrame=(CFrameWnd*)AfxGetMainWnd();
CFrameWnd* pActiveFrame=pMainFrame->GetActiveFrame();
CDocument* pActiveDoc=pActiveFrame->GetActiveDocument();