(假设要从CTestAView中取得指向其它视图类的指针)
CView* CTestAView::GetView(CRuntimeClass* pClass)
{ CTestDoc* pDoc=(CTestDoc*)GetDocument();
CView* pView;
POSITION pos=pDoc->GetFirstViewPosition();
while(pos!=NULL) {
pView=pDoc->GetNextView(pos);
if(pView->IsKindOf(pClass))
break;
}
if(!pView->IsKindOf(pClass))
return NULL;
return pView;
}
有了此函数;当要从CTestAView中取得CTestBView的指针时,只需如下: CTestBView* pTestbView=(CTestBView*)GetView(RUNTIME_CLASS(CTestBView));
从一个视图类取得另一视图类的指针
最新推荐文章于 2021-06-22 20:17:37 发布