从一个视图类取得另一视图类的指针

    技术2022-05-11  36

    (假设要从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));


    最新回复(0)