以前一直通过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));