home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
sibylft1.zip
/
DOC.DAT
/
DOC
/
SPCC
/
PRINTERS.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1997-04-07
|
6KB
|
156 lines
{************************************************}
{ }
{ Speed-Pascal 2.0 Printer Support Unit }
{ }
{ Copyright (c) 1996-1997 Joerg Pleumann }
{ }
{ Please mail all bugs and suggestions to: }
{ }
{ Internet: pleumann @ uni-duisburg.de }
{ FidoNet: Joerg Pleumann @ 2:2448/136.6 }
{ }
{************************************************}
unit Printers;
interface
{$r Printers.srf}
uses
OS2Def, PmSpl, SysUtils, Classes, Forms;
type
EPrinter = class(Exception);
{ Raised in case of printer errors. }
TPrinterOrientation = (poPortrait, poLandscape);
{ Used for Orientation property. }
TPrinterState = (psNoHandle, psHandleIC, psHandleDC);
{ Internal. }
TQueueInfo = array[0..1023] of PRQINFO3;
PQueueInfo = ^TQueueInfo;
{ Internal. }
TDeviceInfo = array[0..1023] of PRDINFO3;
PDeviceInfo = ^TDeviceInfo;
{ Internal. }
TPrinter = class
private
FQueues: PQueueInfo; // Pointer to queue info buffer
FQueueCount: LongInt; // Number of queues available
FQueueIndex: LongInt; // Currently selected queue
FQueueSize: LongInt; // Size of queue info buffer
FDevices: PDeviceInfo; // Pointer to device info buffer
FDeviceCount: LongInt; // Number of devices available
FDeviceIndex: LongInt; // Currently selected device
FDeviceSize: LongInt; // Size of device info buffer
FDeviceName: cstring[32]; // Name of currently selected device
FDeviceData: DEVOPENSTRUC; // Data needed to open device contect
FPrintToFile: Boolean; // Print to file instead of printer?
FFileName: AnsiString; // Name of output file
FPrinters: TStrings; // Printer names visible to end user
FHandle: HDC; // Printer device context
FCanvas: TCanvas; // Printer canvas
FState: TPrinterState; // Current state of printer object
FTitle: AnsiString; // Document title
FCopies: LongInt; // Number of copies to be printed
FAborted: Boolean; // True when last job was aborted
FPageNumber: LongInt; // Number of current page
procedure Error(ID: Word);
procedure FmtError(ID: Word; Args: array of const);
function GetOrientation: TPrinterOrientation;
function GetPageHeight: LongInt;
function GetPageWidth: LongInt;
procedure GetPrinterInfo;
function GetPrinting: Boolean;
procedure SetFileName(Value: AnsiString);
procedure SetPrinterIndex(Value: LongInt);
procedure SetPrinterState(Value: TPrinterState);
procedure SetPrintToFile(Value: Boolean);
public
constructor Create;
{ Create printer object. One printer object
is automatically created and stored in the
Printer variable. No need to create more
printer objects. }
destructor Destroy; override;
{ Destroy printer object. The instance stored
in the Printer variable is automatically
destroyed in the unit's finalization code. }
procedure Abort;
{ Abort current document. Only available inside
document. }
procedure BeginDoc;
{ Begin new document. Only available when last
job has either been completed or aborted. }
procedure EndDoc;
{ End document. Only available inside document. }
procedure NewPage;
{ Start a new, blank page. Only available inside
document. }
procedure OptionsDlg;
{ Display job properties dialog for currently
selected printer. Allow the user to change
job properties. Only available while not in
document. }
property Aborted: Boolean read FAborted;
{ True if last job has been aborted. }
property Canvas: TCanvas read FCanvas;
{ Printer canvas. Only available inside
document. }
property Copies: LongInt read FCopies write FCopies;
{ Number of copies to be printed of next
document. Must be set before BeginDoc,
otherwise ignored. }
property FileName: AnsiString read FFileName write SetFileName;
{ Destination when printing to a file. }
property Handle: HDC read FHandle;
{ Printer device context. }
property Orientation: TPrinterOrientation read GetOrientation;
{ Page orientation. }
property PageHeight: LongInt read GetPageHeight;
{ Page height in pixels. }
property PageNumber: LongInt read FPageNumber;
{ Current page number. }
property PageWidth: LongInt read GetPageWidth;
{ Page width in pixels. }
property PrinterIndex: LongInt read FQueueIndex write SetPrinterIndex;
{ Currently selected printer. Change only while not
in document. Set PrinterIndex to -1 for system
default printer. }
property Printers: TStrings read FPrinters;
{ Names of printers (aka queues) available. If
Printers.Count is 0, the system doesn't have
any printers installed. }
property Printing: Boolean read GetPrinting;
{ True when inside document. }
property PrintToFile: Boolean read FPrintToFile write SetPrintToFile;
{ When True, output is sent to file specified
in the FileName property. }
property Title: AnsiString read FTitle write FTitle;
{ Title of next document. Must be set before
BeginDoc, otherwise ignored. }
end;
var
Printer: TPrinter;
implementation