怎样让GetActiveView以及GetActiveDocument的返回值不为NULL?
我的代码是这样的,自己建立一个基类为CMDIChildWnd的类CMyMDIWnd,里面有这样一些代码:
int CMyMDIWnd::SetLstInfo(int nObjFlag)
{
CDataDoc *pDoc = NULL;
CView *pView = NULL;
CDocument *pDocTemp = NULL;
pView = this->GetActiveView();
pDocTemp = this->GetActiveDocument() ;
if(!pDocTemp) return 0;
if(!pDocTemp->IsKindOf(RUNTIME_CLASS(CDataDoc)))
return 0;
pDoc = (CDataDoc*) pDocTemp;
if(pDoc) {
pDoc->SetViewData(nObjFlag);
return 1;
}
return 0;
}
请问,为什么调用时pView以及pDocTemp里的值总是为空呢?怎样让GetActiveView以及GetActiveDocument的返回值不为NULL?