Book Image

Microsoft Visual C++ Windows Applications by Example

By : Stefan Bjornander, Stefan Björnander
Book Image

Microsoft Visual C++ Windows Applications by Example

By: Stefan Bjornander, Stefan Björnander

Overview of this book

Table of Contents (15 chapters)
Microsoft Visual C++ Windows Applications by Example
Credits
About the Author
About the Reviewer
Preface
Index

The FigureFileManager Class


Since the user can save and load drawings, we need to manage the saving and loading of figure class objects. There is really no problem in saving them, we just call Serialize for each figure class object. However, when it comes to loading figures, we must know which concrete class has been saved. Here is where FigureFileManager comes into the picture. Before the figure object is saved, a FigureFileManager is created, it saves an identity value connected to the figure class before the contents of the figure are saved. When a file is loaded, first the identity value is read by the FigureFileManager. It then creates an object of the class connected to the identity value. After that, we just serialize the object.

One advantage of this system is that if we would like to add another figure to our drawing program, we just need to modify this class, figure classes do not need to be modified. A similar effect can be archived by the use of the CArchive classes WriteClass...