1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
PrintDialog1: TPrintDialog;
procedure Button1Click(Sender: TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Form1: TForm1;
implementation
uses WinSpool, Printers;
{$R *.dfm}
function PrinterSupportsDuplex: Boolean;
var
Device, Driver, Port: array[0..255] of Char;
hDevMode: THandle;
begin
Printer.GetPrinter(Device, Driver, Port, hDevmode);
Result :=
WinSpool.DeviceCapabilities(Device, Port, DC_DUPLEX, nil, nil) <>
0;
end;
procedure ForceDuplexMode;
var
Device, Driver, Port: array[0..80] of Char;
DevMode: THandle;
pDevmode: PDeviceMode;
begin
Printer.GetPrinter(Device, Driver, Port, DevMode);
if Devmode <> 0 then begin
pDevMode := GlobalLock(Devmode);
if pDevmode <> nil then
try
with pDevmode^ do begin
dmDuplex := DMDUP_VERTICAL;
dmFields := dmFields or DM_DUPLEX;
end;
finally
GlobalUnlock(Devmode);
end;
end; { If }
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if PrintDialog1.Execute then
begin
ForceDuplexMode;
Printer.BeginDoc;
printer.canvas.TextOut(10,10,'Recto');
Printer.NewPage;
printer.canvas.TextOut(10,10,'Verso');
Printer.EndDoc;
end;
end;
end. |
Partager