VC single text Separation Dynamic Replacement Multi-view Code Analysis Tommy @ 2004-09-21 14:39 The interface design of the IMAKER2000 is the DOC / View structure, involving Single Document's multi-view-cutting switching. Oh, the light is a little bit. The VC is indeed troublesome, but I don't believe that it is better than VB or Delphi, and flexibility will be better. However, on the perspective of the project, the VC industry is also in practice. If you want to do large-scale, it is a simple and easy tool. I found a long-standing code online, I finally found a Project that implemented the corresponding function in Codegure. Take time, dizzy! In 1998, forget it, it can realize the function. The process of establishing a view will not say much, this is mainly to say how to switch. There is a more common switching without a cut, and the VC technology has a detailed code, I will put the code together.
There are two main functions with a division, one is a function of the establishment, one is a function of switching, two substantially very similar, here analyzing the function of switching: void cmainframe :: OnswitchView1 () {// Todo: Add Your Command Handler Code Here CRectR; GetClientRect (& CR); // Get the display area of the client area CSIZE PANSIZE1 (3 * cr.width () / 4, cr.Height ()); // Set the new View size ccreateContext Context; // declare the document view contact structure and set its contents Context.m_pNewViewClass = RUNTIME_CLASS (CSwitchView1); Context.m_pCurrentDoc = ((CSwitchApp *) AfxGetApp ()) -> m_pDoc; Context.m_pCurrentFrame = this; Context.m_pNewDocTemplate = Context.m_pCurrentDoc-> GetDocTemplate (); Context.m_pLastView = (CView *) m_wndSplitter.GetPane (0,0); m_wndSplitter.DeleteView (0, 1); // delete the row 1 column 2 View m_wndSplitter.CreateView ( 0, 1, Runtime_Class (CSWITCHVIEW1), PANSI11, & Context); // Dynamic Create View1 CSwitchView1 * PView = (CSwitchView1 *) m_wndsplitter.getpane (0, 1); // Get the pointer of the split window PView-> getParentFrame () -> RecalcLayout (); // Redraw main window m_wndsplitter.RecLayout (); // Re-draw the separator window PView-> OnInitialUpdate (); // Estimate is some initialization operation M_Wndsplitter.SetActivePane (0, 1); / / Activate the new separation area} Without a separate code as follows: Void CMAINFRAME :: SwitchToview (int nform) { // CDocument * pDoc = GetActiveDocument (); CView * pOldActiveView = GetActiveView (); // save the old view CView * pNewActiveView = (CView *) GetDlgItem (nForm); // get a new view if (pNewActiveView == NULL) {switch (nform) // These ids are the markers of the dialog, but they can also use other flags {case IDd_dialog1: pnewactiveview = (cView *) new TForm; Break; Case IDd_formview: pnewactiveview = (cView *) new TFORM2; BREAK; } CcreateContext context; // Connect the text.m_pcurrentdoc = PoldActiveView-> getDocument (); pnewactiveview->