标签:
1.新建一个是继承CView的新类CViewSecond
2.menu中建两个菜单,在mainframe中添加对应的消息响应OnDataView,On3dView
mainframe中添加成员变量m_curView;下面代码中ShowWindow(SW_SHOWMAXIMIZED),参数一定是最大化的参数啊,千万别写SW_SHOW,debug好大会儿,发现参数为SW_SHOW的时候视图rect为0啊,0啊。。。。只有移动窗口的时候才显示opengl,发现,ondraw函数死活不被调用,然后消息响应onpaint添加ondraw也不行。。。 最后试试试试 。。。参数的问题。。。。。残念啊。。。
1 void CMainFrame::On3dView() 2 { 3 // TODO: 在此添加命令处理程序代码 4 if (m_curView == ID_3D_VIEW) 5 { 6 return; 7 } 8 CView* pOldActiveView = GetActiveView(); 9 CRuntimeClass* pNewViewClass; 10 pNewViewClass = RUNTIME_CLASS(CViewSecond); 11 CCreateContext context; 12 context.m_pNewViewClass = pNewViewClass; 13 context.m_pCurrentDoc = GetActiveDocument(); 14 CView* pNewView = STATIC_DOWNCAST(CView, CreateView(&context)); 15 if (pNewView != NULL) 16 { 17 pNewView->ShowWindow(SW_SHOWMAXIMIZED); 18 pNewView->OnInitialUpdate(); 19 SetActiveView(pNewView); 20 RecalcLayout(TRUE); 21 m_curView = ID_3D_VIEW; 22 pOldActiveView->DestroyWindow(); 23 } 24 25 26 } 27 28 void CMainFrame::OnDataView() 29 { 30 // TODO: 在此添加命令处理程序代码 31 if (m_curView == ID_DATA_VIEW) 32 { 33 return; 34 } 35 CView* pOldActiveView = GetActiveView(); 36 CRuntimeClass* pNewViewClass; 37 pNewViewClass = RUNTIME_CLASS(CDocView); 38 CCreateContext context; 39 context.m_pNewViewClass = pNewViewClass; 40 context.m_pCurrentDoc = GetActiveDocument(); 41 CView* pNewView = STATIC_DOWNCAST(CView, CreateView(&context)); 42 if (pNewView != NULL) 43 { 44 pNewView->ShowWindow(SW_SHOWMAXIMIZED); 45 pNewView->OnInitialUpdate(); 46 SetActiveView(pNewView); 47 RecalcLayout(); 48 m_curView = ID_DATA_VIEW; 49 pOldActiveView->DestroyWindow(); 50 } 51 52 }
3.CViewSecond中添加相应的初始化OpenGL的各种东西,OK。。。。
标签:
原文地址:http://www.cnblogs.com/AZ-ZK/p/4222441.html