home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / progwin / chap15 / print1.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-11-12  |  1.1 KB  |  43 lines

  1. /*---------------------------------------
  2.    PRINT1.C -- Bare Bones Printing
  3.                (c) Charles Petzold, 1990
  4.   ---------------------------------------*/
  5.  
  6. #include <windows.h>
  7.  
  8. HDC  GetPrinterDC (void) ;              // in PRINT.C
  9. void PageGDICalls (HDC, short, short) ;
  10.  
  11. HANDLE hInst ;
  12. char   szAppName [] = "Print1" ;
  13. char   szCaption [] = "Print Program 1" ;
  14.  
  15. BOOL PrintMyPage (HWND hwnd)
  16.      {
  17.      static char szMessage [] = "Print1: Printing" ;
  18.      BOOL        bError = FALSE ;
  19.      HDC         hdcPrn ;
  20.      short       xPage, yPage ;
  21.  
  22.      if (NULL == (hdcPrn = GetPrinterDC ()))
  23.           return TRUE ;
  24.  
  25.      xPage = GetDeviceCaps (hdcPrn, HORZRES) ;
  26.      yPage = GetDeviceCaps (hdcPrn, VERTRES) ;
  27.  
  28.      if (Escape (hdcPrn, STARTDOC, sizeof szMessage - 1, szMessage, NULL) > 0)
  29.           {
  30.           PageGDICalls (hdcPrn, xPage, yPage) ;
  31.  
  32.           if (Escape (hdcPrn, NEWFRAME, 0, NULL, NULL) > 0)
  33.                Escape (hdcPrn, ENDDOC, 0, NULL, NULL) ;
  34.           else
  35.                bError = TRUE ;
  36.           }
  37.      else
  38.           bError = TRUE ;
  39.  
  40.      DeleteDC (hdcPrn) ;
  41.      return bError ;
  42.      }
  43.