SDI中pDoc获得pView方法

来源:互联网 发布:精修图片软件 编辑:程序博客网 时间:2024/05/19 13:42

以前一直通过pMainWnd中转 其实可以写个函数调用 

.h

CView* GetView(CRuntimeClass* pClass);

.cpp

CView* CxxxDoc::GetView(CRuntimeClass* pClass){CView* pView;POSITION pos = GetFirstViewPosition();while(pos != NULL){pView = GetNextView(pos);if(!pView->IsKindOf(pClass)){break;}}if(!pView->IsKindOf(pClass)){AfxMessageBox(_T("View Pointer Error"));return NULL;}return pView;}

调用的时候记得这样

CxxxView *pView= (CxxxView *)GetView(RUNTIME_CLASS(CxxxView));


原创粉丝点击