正在做一个MFC的程序,遇到了这个问题,因为程序需要,于是用下面的代码创建子窗口:
m_PDoc=new CDoc();
m_PChildFrame2=new CChildFrame2();
CCreateContext context;
context.m_pNewViewClass=RUNTIME_CLASS(CView2);
context.m_pCurrentDoc=m_PDoc;
if(m_PChildFrame2->Create(NULL,NULL,WS_CHILD | WS_VISIBLE | WS_OVERLAPPEDWINDOW, CRect(0,0,860,500),NULL,&context))
return;
m_PChildFrame2->ShowWindow(SW_SHOWMAXIMIZED);
m_PChildFrame2->InitialUpdateFrame(NULL,true);
//CDOC继承自CDocument ,CChildFrame2继承自CMDIChildWnd,CView2继承自CView
现在要从CChildFrame2中发送消息到CView2,问题出来了,在CChildFrame2中用this->GetActiveView()返回NULL,但是此时视图已经处于显示状态。在主框架中用GetActiveFrame(),再用GetActiveView()还是为NULL。