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 Page


A document can be divided into several pages. A paragraph is never split over two pages. If there is not enough room for it in the rest of the page, it is moved in full to the next page. Page is a small class. Its task is to keep track of the first and last paragraph of a page.

Page.h

class Page
{
  public:
    Page();
    Page(int iFirstParagraph, int iLastParagraph);
    int GetFirstParagraph() const {return m_iFirstParagraph;}
    int GetLastParagraph() const {return m_iLastParagraph;}

    void Serialize(CArchive& archive);
  private:
    int m_iFirstParagraph, m_iLastParagraph;
};

Page needs a default constructor beacuse its objects are stored in m_pageArray in the document class.

Page.cpp

Page::Page()
 :m_iFirstParagraph(0),
  m_iLastParagraph(0)
{
  // Empty.
}

Page::Page(int iFirstParagraph, int iLastParagraph)
 :m_iFirstParagraph(iFirstParagraph),
  m_iLastParagraph(iLastParagraph)
{
  // Empty.
}

void Page::Serialize(CArchive& archive)
{
  if (archive.IsStoring...