1. Create a new class that inherits CView Cviewsecond
Two menu in 2.menu, add corresponding message response in mainframe Ondataview,on3dview
Mainframe add member variable M_curview; The following code ShowWindow (sw_showmaximized), parameters must be maximized parameters Ah, do not write sw_show,debug good assembly son, found that the parameter is Sw_ Show when the view rect is 0 Ah, 0 ah .... Only when the window is moved to display OpenGL, found that the OnDraw function is not called, and then the message response OnPaint add OnDraw also not ... Finally try ... parameter of the problem ..... The remnant of the reading Ah ...
1 voidCmainframe::on3dview ()2 {3 //TODO: Add Command handler code here4 if(M_curview = =Id_3d_view)5 {6 return;7 }8cview* Poldactiveview =GetActiveView ();9cruntimeclass*Pnewviewclass;TenPnewviewclass =Runtime_class (cviewsecond); One CCreateContext context; AContext.m_pnewviewclass =Pnewviewclass; -Context.m_pcurrentdoc =getactivedocument (); -cview* Pnewview = Static_downcast (CView, CreateView (&context)); the if(Pnewview! =NULL) - { -Pnewview->ShowWindow (sw_showmaximized); -Pnewview->OnInitialUpdate (); + SetActiveView (pnewview); - RecalcLayout (TRUE); +M_curview =Id_3d_view; APoldactiveview->DestroyWindow (); at } - - - } - - voidCmainframe::ondataview () in { - //TODO: Add Command handler code here to if(M_curview = =Id_data_view) + { - return; the } *cview* Poldactiveview =GetActiveView (); $cruntimeclass*Pnewviewclass;Panax NotoginsengPnewviewclass =Runtime_class (cdocview); - CCreateContext context; theContext.m_pnewviewclass =Pnewviewclass; +Context.m_pcurrentdoc =getactivedocument (); Acview* Pnewview = Static_downcast (CView, CreateView (&context)); the if(Pnewview! =NULL) + { -Pnewview->ShowWindow (sw_showmaximized); $Pnewview->OnInitialUpdate (); $ SetActiveView (pnewview); - RecalcLayout (); -M_curview =Id_data_view; thePoldactiveview->DestroyWindow (); - }Wuyi the}
Add the appropriate initialization OpenGL for the various things in 3.CViewSecond, OK ....
Single Document switching OpenGL view