home *** CD-ROM | disk | FTP | other *** search
/ PC Format Collection 48 / SENT14D.ISO / tech / delphi / disk14 / doc.pak / PRINTERS.INT < prev    next >
Encoding:
Text File  |  1995-08-24  |  3.8 KB  |  89 lines

  1. {*******************************************************}
  2. {                                                       }
  3. {       Delphi Visual Component Library                 }
  4. {                                                       }
  5. {       Copyright (c) 1995 Borland International        }
  6. {                                                       }
  7. {*******************************************************}
  8.  
  9. unit Printers;
  10.  
  11. interface
  12.  
  13. uses WinTypes, SysUtils, Classes, Graphics, Forms;
  14.  
  15. type
  16.   EPrinter = class(Exception);
  17.  
  18.   { TPrinter }
  19.  
  20.   { The printer object encapsulates the printer interface of Windows.  A print
  21.     job is started whenever any redering is done either through a Text variable
  22.     or the printers canvas.  This job will stay open until EndDoc is called or
  23.     the Text variable is closed.  The title displayed in the Print Manager (and
  24.     on network header pages) is determined by the Title property.
  25.  
  26.     EndDoc - Terminates the print job (and closes the currently open Text).
  27.       The print job will being printing on the printer after a call to EndDoc.
  28.     NewPage - Starts a new page and increments the PageNumber property.  The
  29.       pen position of the Canvas is put back at (0, 0).
  30.     Canvas - Represents the surface of the currently printing page.  Note that
  31.       some printer do not support drawing pictures and the Draw, StretchDraw,
  32.       and CopyRect methods might fail.
  33.     Fonts - The list of fonts supported by the printer.  Note that TrueType
  34.       fonts appear in this list even if the font is not supported natively on
  35.       the printer since GDI can render them accurately for the printer.
  36.     PageHeight - The height, in pixels, of the page.
  37.     PageWidth - The width, in pixels, of the page.
  38.     PageNumber - The current page number being printed.  This is incremented
  39.       when ever the NewPage method is called.  (Note: This property can also be
  40.       incremented when a Text variable is written, a CR is encounted on the
  41.       last line of the page).
  42.     PrinterIndex - Specifies which printer in the TPrinters list that is
  43.       currently selected for printing.  Setting this property to -1 will cause
  44.       the default printer to be selected.  If this value is changed EndDoc is
  45.       called automatically.
  46.     Printers - A list of the printers installed in Windows.
  47.     Title - The title used by Windows in the Print Manager and for network
  48.       title pages. }
  49.  
  50.   TPrinterOrientation = (poPortrait, poLandscape);
  51.  
  52.   TPrinter = class(TObject)
  53.   public
  54.     constructor Create;
  55.     destructor Destroy; override;
  56.     procedure Abort;
  57.     procedure BeginDoc;
  58.     procedure EndDoc;
  59.     procedure NewPage;
  60.     procedure GetPrinter(ADevice, ADriver, APort: PChar; var ADeviceMode: THandle);
  61.     procedure SetPrinter(ADevice, ADriver, APort: PChar; ADeviceMode: THandle);
  62.     property Aborted: Boolean;
  63.     property Canvas: TCanvas;
  64.     property Fonts: TStrings;
  65.     property Handle: HDC;
  66.     property Orientation: TPrinterOrientation;
  67.     property PageHeight: Integer;
  68.     property PageWidth: Integer;
  69.     property PageNumber: Integer;
  70.     property PrinterIndex: Integer;
  71.     property Printing: Boolean;
  72.     property Printers: TStrings;
  73.     property Title: string;
  74.   end;
  75.  
  76. var
  77.   Printer: TPrinter;
  78.  
  79. { AssignPrn - Assigns a Text variable to the currently selected printer.  Any
  80.       Write or Writeln's going to that file variable will be written on the
  81.       printer using the Canvas property's font.  A new page is automatically
  82.       started if a CR is encountered on (or a Writeln is written to) the last
  83.       line on the page.  Closing the text file will imply a call to the
  84.       Printer.EndDoc method. Note: only one Text variable can be open on the
  85.       printer at a time.  Opening a second will cause an exception.}
  86. procedure AssignPrn(var F: Text);
  87.  
  88. implementation
  89.