SAMPLE: Text Output Using CScrollView Derivative

Last reviewed: July 10, 1997
Article ID: Q112385
1.00 1.50 1.51 1.52 | 1.00 2.00 2.10
WINDOWS             | WINDOWS NT
kbprg kbfile

The information in this article applies to:

  • The Microsoft Foundation Classes (MFC) included with:

        - Microsoft Visual C++ for Windows, version 1.0, 1.50, 1.51, and
          1.52
        - Microsoft Visual C++ 32-bit Edition, version 1.0, 2.0, and 2.1
    

SUMMARY

The TEXT sample demonstrates how to display and print text using a CScrollView derived class. It is possible to implement text output in a CScrollView class by overriding OnDraw and drawing the entire document using TextOut. However, further steps are required to draw the text efficiently and to include support for multipage documents. Here are the features implemented in this sample and the locations:

Feature                                        Locations(s)
-------                                        ------------

Calculation of various metrics necessary       METRICS.CPP:
for text output:                               CViewMetrics::Compute


Optimized screen and printer output for        TEXTVIEW.CPP:
multipage documents:                           OnDraw (two overrides)
                                               OnPrint
                                               ComputeVisibleLines
                                               ComputePrintableLines

Calculation of page count:                     METRICS.CPP:
                                               CPageMetrics::Compute

Visual indication of pagination:               METRICS.CPP (Calculation)
                                               CPageMetrics::IsPageBreak

                                               TEXTVIEW.CPP (Display)
                                               OnDraw
                                               DrawPageBreak

User-defined margins:                          METRICS.CPP (Calculation)
                                               CMargins::Compute

                                               METRICS.CPP (Validation)
                                               CMargins::IsInvalid

                                               TEXTVIEW.CPP (Display)
                                               OnPrint

Loading text files into a document:            TEXTDOC.CPP
                                               OnOpenDocument


TEXT.EXE can be downloaded as a self-extracting file from the Microsoft Software Library (MSL) on the following services:
  • Microsoft Download Service (MSDL)

          Dial (206) 936-6735 to connect to MSDL
          Download TEXT.EXE (size: 46630 bytes) 
    
  • Internet (anonymous FTP)

          ftp ftp.microsoft.com
          Change to the \softlib\mslfiles directory
          Get TEXT.EXE (size: 46630 bytes) 
    


Additional reference words: kbinf 1.00 1.50 1.51 1.52 2.00 2.10 2.50 2.51
2.52 3.00 3.10 mfc text output print preview
KBCategory: kbprg kbfile
KBSubcategory: MfcUI
Keywords : MfcUI kbfile kbprg
Technology : kbMfc
Version : 1.00 1.50 1.51 1.52 | 1.00 2.00
Platform : NT WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 10, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.