在CMainFrame::OnCreate中调用视图类成员 前提是CyourappView的声明时已经把CMainFrame类作为友元类,否则无法调用视图受保护和私有成员
//获得文档模板:
POSITION curTemplatePos = theApp.GetFirstDocTemplatePosition();
CDocTemplate *m_doc=theApp.GetNextDocTemplate(curTemplatePos);//获得文档:
curTemplatePos=m_doc->GetFirstDocPosition();
CintefaceDoc *m_pdoc=(CintefaceDoc*)m_doc->GetNextDoc(curTemplatePos);
//获得视图:
curTemplatePos=m_pdoc->GetFirstViewPosition();
CintefaceView *m_pview=(CintefaceView*)m_pdoc->GetNextView(curTemplatePos);
//调用视图成员:
(m_pview->m_wndVideo).DockToWindow(&m_wndOutput,CBRS_ALIGN_TOP);
m_pview->m_wndMap.AttachToTabWnd (&(m_pview->m_wndVideo), BCGP_DM_STANDARD,FALSE, NULL);
本文介绍如何在MFC的CMainFrame类中调用视图类(CyourappView)的成员函数,需要先将CMainFrame声明为视图类的友元类。文章详细展示了获取文档模板、文档及视图对象的过程,并最终调用视图的成员函数。
880

被折叠的 条评论
为什么被折叠?



