Author: Peter Below
How to set a printer to duplex mode?
Answer:
You typically switch a printer to duplex mode by changing its TDeviceMode(API:
DEVMODE)record .But first you should test whether the installed printer driver
supports this:
1 uses
2 printers, winspool;
3
4 function PrinterSupportsDuplex: Boolean;
5 var
6 Device, Driver, Port: array[0..255] of Char;
7 hDevMode: THandle;
8 begin
9 Printer.GetPrinter(Device, Driver, Port, hDevmode);
10 Result := WinSpool.DeviceCapabilities(Device, Port, DC_DUPLEX, nil, nil) <> 0;
11 end;
If it does you can try to switch the duplex mode on before you call
richedit.print:
12 var
13 Device, Driver, Port: array[0..80] of Char;
14 DevMode: THandle;
15 pDevmode: PDeviceMode;
16 begin
17 // Get printer device mode handle.
18 Printer.GetPrinter(Device, Driver, Port, DevMode);
19 if Devmode <> 0 then
20 begin
21 // lock it to get pointer to DEVMODE record
22 pDevMode := GlobalLock(Devmode);
23 if pDevmode <> nil then
24 try
25 with pDevmode^ do
26 begin
27 dmDuplex := DMDUP_VERTICAL;
28 dmFields := dmFields or DM_DUPLEX;
29 end;
30 finally
31 // unlock devmode handle.
32 GlobalUnlock(Devmode);
33 end;
34 end; { If }
35 end;
|