home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Freelog 11
/
Freelog011.iso
/
BestOf
/
PhoenixMail
/
Source
/
comps
/
XPrinter.pas
< prev
Wrap
Pascal/Delphi Source File
|
1999-02-20
|
22KB
|
747 lines
{*****************************************************************************
*
* Parts of this code were changed by Michael Haller
* E-mail: michael@discountdrive.com
* Homepage: http://www.discountdrive.com/sunrise/
*
* The copyright has the original author of this code.
*
*****************************************************************************}
(*********************************************************************)
(* *)
(* XPrint: Eine Komponente zur gerΣteunabhΣngigen Druckerausgabe *)
(* *)
(* (c) 1997 Rainer Reusch fⁿr Toolbox *)
(* (c) 1997 Rainer Reusch fⁿr Computer & Literatur *)
(* *)
(* Borland Delphi 1.0, 2.0, 3.0, Borland C++Builder 1.0 *)
(* *)
(****V1.4*************************************************************)
{$A+,B-,C-,D-,E-,F-,G+,H+,I-,J+,K-,L-,M-,N-,O+,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y-,Z1}
UNIT XPrinter;
INTERFACE
USES
{$IFDEF VER80}
WinTypes,
{$ELSE}
WinSpool,
{$ENDIF}
WinProcs, Classes, Graphics, SysUtils, Printers;
TYPE
TXPrinterOrientation = (xpoPortrait, xpoLandscape);
TXPrinterCapability = (xpcCopies, xpcOrientation, xpcCollation);
TXPrinterCapabilities = SET OF TXPrinterCapability;
TScaling = (pscDot, { Skalierungseinheit "Pixel" (gerΣteabhΣngig) }
pscMil, { 1/1000" }
pscMetric10, { 1/10mm }
pscMetric100); { 1/100mm }
TXPrint = CLASS (TComponent)
PRIVATE
{ Eigenschaften }
fScaling : TScaling; { eingestellte Skalierung }
fMarginLeft, { Randeinstellungen }
fMarginTop,
fMarginRight,
fMarginBottom : INTEGER;
fPrintWidth, { bedruckbarer Bereich }
fPrintHeight : INTEGER;
fPrintersInstalled : WORD; { Anzahl vorhandener Drucker }
{ Druckerparameter }
pLogPixelsX, { Aufl÷sung (dpi) }
pLogPixelsY,
pPhysicalWidth, { Blattgr÷▀e in Pixeln }
pPhysicalHeight,
pHorzRes, { bedruckbarer Bereich in Pixeln }
pVertRes,
pPhysicalOffsetX, { Abstand bedruckbarer Bereich vom Blattrand }
pPhysicalOffsetY : INTEGER;
{ fⁿr den internen Gebrauch }
k : INTEGER; { Skalierungsfaktor }
FontBackup : TFont; { Backup fⁿr Font }
SizeBackup : INTEGER; { zuletzt eingestellte Font-Gr÷▀e in Twips }
PrintOpened : BOOLEAN; { true, nach BeginDoc }
DummyCreated: BOOLEAN; { true, wenn Dummy-Canvas angelegt wurde }
FUNCTION PrintersInstalled : WORD;
PROCEDURE SetupPrinter;
PROCEDURE SetScaling(VALUE : TScaling);
FUNCTION GetPrinterAvailable : BOOLEAN;
FUNCTION GetPrinting : BOOLEAN;
FUNCTION GetFont : TFont;
PROCEDURE SetFont(VALUE : TFont);
FUNCTION GetAborted : BOOLEAN;
FUNCTION GetMinMarginLeft : INTEGER;
FUNCTION GetMinMarginTop : INTEGER;
FUNCTION GetMinMarginRight : INTEGER;
FUNCTION GetMinMarginBottom : INTEGER;
FUNCTION GetPrinterCapabilities : TXPrinterCapabilities;
FUNCTION GetCopies : INTEGER;
PROCEDURE SetCopies(VALUE : INTEGER);
FUNCTION GetFonts : TStrings;
FUNCTION GetHandle: HDC;
FUNCTION GetPageNumber : INTEGER;
FUNCTION GetPrinters : TStrings;
FUNCTION GetTitle : STRING;
PROCEDURE SetTitle(VALUE : STRING);
FUNCTION GetCurrentPrinter : INTEGER;
PROCEDURE SetCurrentPrinter(VALUE : INTEGER);
FUNCTION GetOrientation : TXPrinterOrientation;
PROCEDURE SetOrientation(VALUE : TXPrinterOrientation);
PROTECTED
PROCEDURE DriverParams;
PROCEDURE ClosePrinting;
FUNCTION DotValX(ScaledVal : INTEGER) : INTEGER;
FUNCTION DotValY(ScaledVal : INTEGER) : INTEGER;
FUNCTION ScaleValX(DotVal : INTEGER) : INTEGER;
FUNCTION ScaleValY(DotVal : INTEGER) : INTEGER;
PUBLIC
Canvas : TCanvas;
CONSTRUCTOR Create(AOwner: TComponent); Override;
DESTRUCTOR Destroy; Override;
PROCEDURE Abort;
PROCEDURE BeginDoc;
PROCEDURE EndDoc;
PROCEDURE NewPage;
PROCEDURE SetFontSize(FontSize : INTEGER);
PROCEDURE SelectFont(AFont : TFont);
FUNCTION XBounds(ALeft, ATop, AWidth, AHeight: INTEGER): tRect;
PROPERTY PrinterAvailable : BOOLEAN Read GetPrinterAvailable;
PROPERTY CurrentPrinter : INTEGER Read GetCurrentPrinter
Write SetCurrentPrinter;
PROPERTY PrintWidth : INTEGER Read fPrintWidth;
PROPERTY PrintHeight : INTEGER Read fPrintHeight;
PROPERTY MinMarginLeft : INTEGER Read GetMinMarginLeft;
PROPERTY MinMarginTop : INTEGER Read GetMinMarginTop;
PROPERTY MinMarginRight : INTEGER Read GetMinMarginRight;
PROPERTY MinMarginBottom : INTEGER Read GetMinMarginBottom;
PROPERTY Capabilities : TXPrinterCapabilities Read GetPrinterCapabilities;
PROPERTY Fonts : TStrings Read GetFonts;
PROPERTY Handle : HDC Read GetHandle;
PROPERTY PageNumber : INTEGER Read GetPageNumber;
PROPERTY Printers : TStrings Read GetPrinters;
PROPERTY Printing : BOOLEAN Read GetPrinting;
PROPERTY XResolution : INTEGER Read pLogPixelsX;
PROPERTY YResolution : INTEGER Read pLogPixelsY;
PUBLISHED
PROPERTY Scaling : TScaling Read fScaling
Write SetScaling
DEFAULT pscDot;
PROPERTY MarginLeft : INTEGER Read fMarginLeft
Write fMarginLeft;
PROPERTY MarginTop : INTEGER Read fMarginTop
Write fMarginTop;
PROPERTY MarginRight : INTEGER Read fMarginRight
Write fMarginRight;
PROPERTY MarginBottom : INTEGER Read fMarginBottom
Write fMarginBottom;
PROPERTY Font : TFont Read GetFont
Write SetFont;
PROPERTY Aborted : BOOLEAN Read GetAborted;
PROPERTY Copies : INTEGER Read GetCopies
Write SetCopies;
PROPERTY Title : STRING Read GetTitle
Write SetTitle;
PROPERTY Orientation : TXPrinterOrientation Read GetOrientation
Write SetOrientation;
END;
PROCEDURE Register;
IMPLEMENTATION
CONSTRUCTOR TXPrint.Create;
BEGIN
Inherited Create(AOwner);
PrintOpened:=FALSE;
pLogPixelsX:=300; { angenommene Werte als Default }
pLogPixelsY:=300;
k:=1;
fPrintersInstalled := 0;
try
DummyCreated:=FALSE;
fPrintersInstalled:=PrintersInstalled;
IF fPrintersInstalled>0 THEN
BEGIN
Canvas:=Printer.Canvas;
Printer.PrinterIndex:=-1;
END
ELSE
BEGIN
Canvas:=TCanvas.Create;
DummyCreated:=TRUE;
END;
PrintOpened:=FALSE;
pLogPixelsX:=300; { angenommene Werte als Default }
pLogPixelsY:=300;
k:=1;
except end;
END;
DESTRUCTOR TXPrint.Destroy;
BEGIN
IF DummyCreated THEN Canvas.Free;
Inherited Destroy;
END;
PROCEDURE TXPrint.DriverParams;
{ Druckertreiber-Parameter ermitteln }
{$IFDEF VER80}
VAR
r : tPoint;
{$ENDIF}
BEGIN
try
IF fPrintersInstalled>0 THEN
BEGIN
pLogPixelsX:=GetDeviceCaps(Printer.Handle,LOGPIXELSX);
pLogPixelsY:=GetDeviceCaps(Printer.Handle,LOGPIXELSY);
{$IFDEF VER80}
Escape(Printer.Handle,GetPhysPageSize,0,NIL,@r);
pPhysicalWidth:=r.x;
pPhysicalHeight:=r.y;
{$ELSE}
pPhysicalWidth:=GetDeviceCaps(Printer.Handle,PHYSICALWIDTH);
pPhysicalHeight:=GetDeviceCaps(Printer.Handle,PHYSICALHEIGHT);
{$ENDIF}
pHorzRes:=GetDeviceCaps(Printer.Handle,HORZRES);
pVertRes:=GetDeviceCaps(Printer.Handle,VERTRES);
{$IFDEF VER80}
Escape(Printer.Handle,GetPrintingOffset,0,NIL,@r);
pPhysicalOffsetX:=r.x;
pPhysicalOffsetY:=r.y;
{$ELSE}
pPhysicalOffsetX:=GetDeviceCaps(Printer.Handle,PHYSICALOFFSETX);
pPhysicalOffsetY:=GetDeviceCaps(Printer.Handle,PHYSICALOFFSETY);
{$ENDIF}
END;
except end;
END;
PROCEDURE TXPrint.ClosePrinting;
BEGIN
IF fPrintersInstalled>0 THEN
BEGIN
{ ursprⁿnglichen Font wieder setzen }
Canvas.Font.Color:=FontBackup.Color;
Canvas.Font.Height:=FontBackup.Height;
Canvas.Font.Name:=FontBackup.Name;
Canvas.Font.Pitch:=FontBackup.Pitch;
Canvas.Font.Size:=FontBackup.Size;
Canvas.Font.Style:=FontBackup.Style;
FontBackup.Free;
END;
PrintOpened:=FALSE;
END;
FUNCTION TXPrint.DotValX(ScaledVal : INTEGER) : INTEGER;
{ Rechnet skalierten Wert in Pixel um,
abhΣngig von der Skalierung und der hor. Druckeraufl÷sung }
BEGIN
IF Scaling=pscDot THEN
DotValX:=ScaledVal
ELSE
DotValX:=LONGINT(ScaledVal)*pLogPixelsX DIV k;
END;
FUNCTION TXPrint.DotValY(ScaledVal : INTEGER) : INTEGER;
{ Rechnet skalierten Wert in Pixel um,
abhΣngig von der Skalierung und der vert. Druckeraufl÷sung }
BEGIN
IF Scaling=pscDot THEN
DotValY:=ScaledVal
ELSE
DotValY:=LONGINT(ScaledVal)*pLogPixelsY DIV k;
END;
FUNCTION TXPrint.ScaleValX(DotVal : INTEGER) : INTEGER;
{ Rechnet einen Pixelwert in skalierten Wert um,
abhΣngig von der Skalierung und der hor. Druckeraufl÷sung }
BEGIN
IF Scaling=pscDot THEN
ScaleValX:=DotVal
ELSE
ScaleValX:=LONGINT(DotVal)*k DIV pLogPixelsX;
END;
FUNCTION TXPrint.ScaleValY(DotVal : INTEGER) : INTEGER;
{ Rechnet einen Pixelwert in skalierten Wert um,
abhΣngig von der Skalierung und der vert. Druckeraufl÷sung }
BEGIN
IF Scaling=pscDot THEN
ScaleValY:=DotVal
ELSE
ScaleValY:=LONGINT(DotVal)*k DIV pLogPixelsY;
END;
PROCEDURE TXPrint.Abort;
{ Druckausgabe abbrechen }
BEGIN
IF fPrintersInstalled>0 THEN
BEGIN
Printer.Abort;
ClosePrinting;
END;
END;
PROCEDURE TXPrint.SetupPrinter;
{ Druckereinstellungen setzen }
VAR
kx1, ky1, ox, oy, i : LONGINT;
kx2, ky2 : INTEGER;
BEGIN
IF fPrintersInstalled>0 THEN
WITH Printer DO
BEGIN
IF fScaling=pscDot THEN
BEGIN { keine Skalierung }
{ bedruckbarer Bereich }
i:=LONGINT(pHorzRes-(MarginLeft-pPhysicalOffsetX)-1); { Pixel }
i:=i-MarginRight+pPhysicalWidth-pPhysicalOffsetX-pHorzRes;
fPrintWidth:=i;
i:=LONGINT(pVertRes-(MarginTop-pPhysicalOffsetY)-1);
i:=i-MarginBottom+pPhysicalHeight-pPhysicalOffsetY-pVertRes;
fPrintHeight:=i;
END
ELSE
BEGIN { Skalierung }
{ bedruckbarer Bereich }
i:=LONGINT(pHorzRes-(DotValX(MarginLeft)-pPhysicalOffsetX)-1); { Pixel }
i:=i-DotValX(MarginRight)+pPhysicalWidth-pPhysicalOffsetX-pHorzRes;
fPrintWidth:=LONGINT(k)*i DIV pLogPixelsX;
i:=LONGINT(pVertRes-(DotValY(MarginTop)-pPhysicalOffsetY)-1);
i:=i-DotValY(MarginBottom)+pPhysicalHeight-pPhysicalOffsetY-pVertRes;
fPrintHeight:=LONGINT(k)*i DIV pLogPixelsY;
{ Skalierung }
kx2:=7200; { ─nderung V1.4 }
ky2:=7200;
kx1:=k*LONGINT(7200 DIV pLogPixelsX);
WHILE kx1>32767 DO
BEGIN
kx1:=kx1 DIV 2;
kx2:=kx2 DIV 2;
END;
ky1:=k*LONGINT(7200 DIV pLogPixelsY);
WHILE ky1>32767 DO
BEGIN
ky1:=ky1 DIV 2;
ky2:=ky2 DIV 2;
END;
SetMapMode(Handle,MM_Isotropic); { Breite und H÷he im gleichen VerhΣltnis }
ox:=(LONGINT(MarginLeft)*pLogPixelsX DIV k)-pPhysicalOffsetX;
oy:=(LONGINT(MarginTop)*pLogPixelsY DIV k)-pPhysicalOffsetY;
{$IFDEF VER80}
SetWindowExt(Handle,kx1,ky1);
SetViewportExt(Handle,kx2,ky2);
SetViewportOrg(Handle,ox,oy);
{$ELSE}
SetWindowExtEx(Handle,kx1,ky1,NIL);
SetViewPortExtEx(Handle,kx2,ky2,NIL);
SetViewPortOrgEx(Handle,ox,oy,NIL);
{$ENDIF}
END;
END;
END;
PROCEDURE TXPrint.BeginDoc;
{ Druckausgabe ÷ffnen }
VAR
FS : INTEGER;
BEGIN
IF fPrintersInstalled>0 THEN
BEGIN
DriverParams; { Druckerparameter ermitteln }
Printer.BeginDoc;
PrintOpened:=TRUE;
SetupPrinter;
WITH Printer DO
BEGIN
{ Korrektur der Font-Aufl÷sung, falls Drucker gewechselt wurde
(geklaut im Quelltext der Unit PRINTERS) }
FS:=Canvas.Font.Size;
Canvas.Font.PixelsPerInch:=pLogPixelsY;
Canvas.Font.Size:=FS;
{ Backup vom aktuellen Font erstellen }
FontBackup:=TFont.Create;
FontBackup.Color:=Canvas.Font.Color;
FontBackup.Height:=Canvas.Font.Height;
FontBackup.Name:=Canvas.Font.Name;
FontBackup.Pitch:=Canvas.Font.Pitch;
FontBackup.Size:=Canvas.Font.Size;
FontBackup.Style:=Canvas.Font.Style;
{ Gr÷▀e des vorgegebenen Fonts anpassen }
FS:=Canvas.Font.Size;
SetFontSize(FS);
END;
END;
END;
PROCEDURE TXPrint.EndDoc;
{ Druckerausgabe schlie▀en }
BEGIN
IF fPrintersInstalled>0 THEN
BEGIN
Printer.EndDoc;
ClosePrinting;
END;
END;
PROCEDURE TXPrint.NewPage;
{ neue Seite }
BEGIN
IF (PrintersInstalled>0) AND PrintOpened THEN
BEGIN
Printer.NewPage;
SetupPrinter;
SetFontSize(SizeBackup);
END;
END;
PROCEDURE TXPrint.SetFontSize;
{ Font-Gr÷▀e setzen }
BEGIN
IF fPrintersInstalled>0 THEN
BEGIN
SizeBackup:=FontSize;
WITH Canvas.Font DO
IF (fScaling=pscDot) OR (NOT PrintOpened) THEN
Size:=Abs(FontSize) { keine Skalierung }
ELSE
Size:=LONGINT(Abs(FontSize))*k DIV PixelsPerInch; { Druckeraufl÷sung berⁿcksichtigen }
END;
END;
PROCEDURE TXPrint.SelectFont(AFont : TFont);
{ Den angegebenen Font als Drucker-Font setzen }
BEGIN
IF fPrintersInstalled>0 THEN
WITH Canvas.Font DO
BEGIN
Height:=-Abs(AFont.Height);
Name:=AFont.Name;
Pitch:=AFont.Pitch;
Style:=AFont.Style;
SetFontSize(AFont.Size);
END;
END;
FUNCTION TXPrint.XBounds(ALeft, ATop, AWidth, AHeight: INTEGER): tRect;
BEGIN
{$IFDEF VER80}
XBounds:=Bounds(DotValX(ALeft),DotValY(ATop),DotValX(AWidth),DotValY(AHeight));
{$ELSE}
XBounds:=Bounds(ALeft,ATop,AWidth,AHeight);
{$ENDIF}
END;
FUNCTION TXPrint.PrintersInstalled : WORD;
{ Ermittelt, wieviele Drucker im System eingerichtet sind }
{$IFDEF VER80}
CONST
DevicesSize = 4096;
VAR
i, j : WORD;
Devices: PChar;
{$ELSE}
VAR
Buffer: PChar;
Count, NumInfo: Integer;
Flags: INTEGER;
Level: BYTE;
{$ENDIF}
BEGIN
PrintersInstalled:=0;
{$IFDEF VER80}
GetMem(Devices, DevicesSize);
TRY
i:=0;
GetProfileString('devices', NIL, '', Devices, DevicesSize);
IF Devices[0]>#0 THEN
BEGIN { mind. ein Drucker ist vorhanden }
j:=0;
REPEAT
Inc(j);
IF Devices[j]=#0 THEN
BEGIN
Inc(i);
Inc(j);
END;
UNTIL Devices[j]=#0;
END;
EXCEPT
i:=0;
END;
FreeMem(Devices, DevicesSize);
PrintersInstalled:=i;
{$ELSE}
TRY
IF Win32Platform = VER_PLATFORM_WIN32_NT THEN
BEGIN
Flags := PRINTER_ENUM_CONNECTIONS OR PRINTER_ENUM_LOCAL;
Level := 4;
END
ELSE
BEGIN
Flags := PRINTER_ENUM_LOCAL;
Level := 5;
END;
EnumPrinters(Flags, NIL, Level, NIL, 0, Count, NumInfo);
GetMem(Buffer, Count);
TRY
IF NOT EnumPrinters(Flags, NIL, Level, PByte(Buffer), Count, Count, NumInfo) THEN
Exit;
PrintersInstalled:=NumInfo;
FINALLY
FreeMem(Buffer, Count);
END;
EXCEPT
PrintersInstalled:=0;
END;
{$ENDIF}
END;
FUNCTION TXPrint.GetPrinterAvailable : BOOLEAN;
{ Liefert true, wenn mindestens ein Drucker vorhanden ist }
BEGIN
GetPrinterAvailable:=fPrintersInstalled>0;
END;
FUNCTION TXPrint.GetPrinting;
{ Prⁿfen, ob gerade eine Druckerausgabe lΣuft }
BEGIN
IF fPrintersInstalled>0 THEN
GetPrinting:=Printer.Printing
ELSE
GetPrinting:=FALSE;
END;
PROCEDURE TXPrint.SetScaling;
{ Skalierung setzen }
VAR
ML, MT, MR, MB : INTEGER;
BEGIN
IF NOT PrintOpened THEN
BEGIN
{ Randpositionen in Pixel umrechnen }
ML:=DotValX(MarginLeft);
MT:=DotValY(MarginTop);
MR:=DotValX(MarginRight);
MB:=DotValY(MarginBottom);
fScaling:=VALUE;
k:=1;
CASE fScaling OF
pscMetric10 : k:=254;
pscMetric100 : k:=2540;
pscMil : k:=1000;
END { case };
{ Randpositionen entsprechend Skalierung umrechnen }
MarginLeft:=ScaleValX(ML);
MarginTop:=ScaleValY(MT);
MarginRight:=ScaleValX(MR);
MarginBottom:=ScaleValY(MB);
END;
END;
FUNCTION TXPrint.GetFont;
{ aktueller Druck-Font }
BEGIN
GetFont:=Canvas.Font
END;
PROCEDURE TXPrint.SetFont;
{ aktuellen Druck-Font setzen (nur die Inhalte) }
BEGIN
Canvas.Font.Color:=VALUE.Color;
Canvas.Font.Height:=VALUE.Height;
Canvas.Font.Name:=VALUE.Name;
Canvas.Font.Pitch:=VALUE.Pitch;
Canvas.Font.Size:=VALUE.Size;
Canvas.Font.Style:=VALUE.Style;
END;
FUNCTION TXPrint.GetAborted;
{ Abfrage auf Abbruch }
BEGIN
IF fPrintersInstalled>0 THEN
GetAborted:=Printer.Aborted
ELSE
GetAborted:=FALSE;
END;
FUNCTION TXPrint.GetMinMarginLeft : INTEGER;
{ linker Rand: kleinstm÷gliche Randposition, gegeben durch den Druckertreiber }
BEGIN
GetMinMarginLeft:=ScaleValX(pPhysicalOffsetX);
END;
FUNCTION TXPrint.GetMinMarginRight : INTEGER;
{ rechter Rand: kleinstm÷gliche Randposition, gegeben durch den Druckertreiber }
BEGIN
GetMinMarginRight:=ScaleValX(pPhysicalWidth-pHorzRes-pPhysicalOffsetX);
END;
FUNCTION TXPrint.GetMinMarginTop : INTEGER;
{ oberer Rand: kleinstm÷gliche Randposition, gegeben durch den Druckertreiber }
BEGIN
GetMinMarginTop:=ScaleValY(pPhysicalOffsetY);
END;
FUNCTION TXPrint.GetMinMarginBottom : INTEGER;
{ unterer Rand: kleinstm÷gliche Randposition, gegeben durch den Druckertreiber }
BEGIN
GetMinMarginBottom:=ScaleValY(pPhysicalHeight-pVertRes-pPhysicalOffsetY);
END;
FUNCTION TXPrint.GetPrinterCapabilities : TXPrinterCapabilities;
{ Druckereigenschaften }
VAR
r : TXPrinterCapabilities;
BEGIN
r:=[];
IF fPrintersInstalled>0 THEN
BEGIN
{$IFNDEF VER80}
IF pcCopies IN Printer.Capabilities THEN r:=[xpcCopies];
IF pcOrientation IN Printer.Capabilities THEN r:=r+[xpcOrientation];
IF pcCollation IN Printer.Capabilities THEN r:=r+[xpcCollation];
{$ENDIF}
END;
GetPrinterCapabilities:=r;
END;
FUNCTION TXPrint.GetCopies;
{ Anzahl Kopien }
BEGIN
Result := 1;
try
IF fPrintersInstalled>0 THEN
BEGIN
{$IFDEF VER80}
GetCopies:=1;
{$ELSE}
GetCopies:=Printer.Copies;
{$ENDIF}
END
ELSE GetCopies:=1;
except end;
END;
PROCEDURE TXPrint.SetCopies;
{ Anzahl Kopien }
BEGIN
try
{$IFNDEF VER80}
// nur IN der 32-Bit-Version unterstⁿtzt
IF fPrintersInstalled>0 THEN Printer.Copies:=VALUE;
{$ENDIF}
except end;
END;
FUNCTION TXPrint.GetFonts;
{ verfⁿgbare Drucker-Fonts }
BEGIN
IF fPrintersInstalled>0 THEN
GetFonts:=Printer.Fonts
ELSE
GetFonts:=NIL;
END;
FUNCTION TXPrint.GetHandle;
{ Drucker-Handle }
BEGIN
IF fPrintersInstalled>0 THEN
GetHandle:=Printer.Handle
ELSE
GetHandle:=0;
END;
FUNCTION TXPrint.GetPageNumber : INTEGER;
{ Seitennummer }
BEGIN
IF fPrintersInstalled>0 THEN
GetPageNumber:=Printer.PageNumber
ELSE
GetPageNumber:=1;
END;
FUNCTION TXPrint.GetPrinters;
{ verfⁿgbare Drucker }
BEGIN
IF fPrintersInstalled>0 THEN
GetPrinters:=Printer.Printers
ELSE
GetPrinters:=NIL;
END;
FUNCTION TXPrint.GetTitle;
{ Druck-Job-Name, erscheint im Druck-Manager }
BEGIN
IF fPrintersInstalled>0 THEN
GetTitle:=Printer.Title
ELSE
GetTitle:='';
END;
PROCEDURE TXPrint.SetTitle;
{ Druck-Job-Name, erscheint im Druck-Manager }
BEGIN
IF fPrintersInstalled>0 THEN
Printer.Title:=VALUE;
END;
FUNCTION TXPrint.GetCurrentPrinter;
{ aktueller Drucker }
BEGIN
IF fPrintersInstalled>0 THEN
GetCurrentPrinter:=Printer.PrinterIndex
ELSE
GetCurrentPrinter:=0;
END;
PROCEDURE TXPrint.SetCurrentPrinter;
{ aktueller Drucker }
BEGIN
IF fPrintersInstalled>0 THEN
BEGIN
Printer.PrinterIndex:=VALUE;
DriverParams; { Druckerparameter ermitteln }
END;
END;
FUNCTION TXPrint.GetOrientation;
{ Ausrichtung }
BEGIN
GetOrientation:=xpoPortrait;
try
IF fPrintersInstalled>0 THEN
GetOrientation:=TXPrinterOrientation(Ord(Printer.Orientation))
ELSE
GetOrientation:=xpoPortrait;
except end;
END;
PROCEDURE TXPrint.SetOrientation;
{ Ausrichtung }
BEGIN
IF fPrintersInstalled>0 THEN
Printer.Orientation:=TPrinterOrientation(Ord(VALUE));
END;
PROCEDURE Register;
{ Registrierung der Komponente }
BEGIN
RegisterComponents('Toolbox',[TXPrint]);
END;
END.