本文主要是介绍SDI中pDoc获得pView方法,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
以前一直通过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));
这篇关于SDI中pDoc获得pView方法的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!