Chapter Sixteen -- Separating the Document from Its View

Chapter Sixteen

Now you're finally going to see the interaction between documents and views. Chapter 13 gave you a preview of this interaction when it showed the routing of command messages to both view objects and document objects. In this chapter, you'll see how the document maintains the application's data and how the view presents the data to the user. You'll also learn how the document and view objects talk to each other while the application executes.

The two examples in this chapter both use the CFormView class as the base class for their views. The first example is as simple as possible, with the document holding only one simple object of class CStudent, which represents a single student record. The view shows the student's name and grade and allows editing. With the CStudent class, you'll get some practice writing classes to represent real-world entities. You'll also get to use the Microsoft Foundation Class (MFC) Library version 6.0 diagnostic dump functions.

The second example goes further by introducing pointer collection classes—the CObList and CTypedPtrList classes in particular. Now the document holds a collection of student records, and the view allows the sequencing, insertion, and deletion of individual records.



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