The EX23C Example -- An MDI Application

Now let's create an MDI application that doesn't use the document-view architecture.

  1. Run AppWizard to produce \vcpp32\ex23c\ex23c. Select the Multiple Documents option in the AppWizard Step 1 dialog and uncheck the Document/View Architecture Support? option, as shown here.

    click to view at full size.

  2. Add code to paint in the dialog. Add the following boldface code to the CChildView::OnPaint function in the ChildView.cpp source code file:

     void CChildView::OnPaint()  {     CPaintDC dc(this); // device context for painting     dc.TextOut(0, 0, "Hello, world!");     // Do not call CWnd::OnPaint() for painting messages } 

  3. Compile and run. You now have a complete MDI application without dependencies on the document-view architecture.

    As in EX23B, this example automatically creates a CChildView class. The main difference between EX23B and EX23C is the fact that in EX23C the CChildView class is created in the CChildFrame::OnCreate function instead of in the CMainFrame class.

In this chapter you've learned how to create three kinds of applications that do not depend on the document-view architecture. Examining how these applications are generated is also a great way to learn how MFC works. We recommend that you compare the generated results to similar applications with document-view architecture support to get a complete picture of how the document-view classes work with the rest of MFC.



Programming Microsoft Visual C++
Programming Microsoft Visual C++
ISBN: 1572318570
EAN: 2147483647
Year: 1997
Pages: 332

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net