whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1541)

Database (90)
Files (137)
Forms (107)
Graphic (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Math (76)
Misc (126)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

26 Visitors Online


 
...Set a Printer to Duplex Mode?
Autor: P. Below
[ Print tip ]  

Tip Rating (28):  
     


{
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:
}
uses
  
printers, winspool;

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, nilnil) <>
    0;
end;

{if it does you can try to switch the duplex mode on before you call
 richedit.print:}


var
  
Device, Driver, Port: array[0..80] of Char;
  DevMode: THandle;
  pDevmode: PDeviceMode;
  begin
     
// Get printer device mode handle.
    
Printer.GetPrinter(Device, Driver, Port, DevMode);
    if Devmode <> 0 then begin
       
// lock it to get pointer to DEVMODE record
      
pDevMode := GlobalLock(Devmode);
      if pDevmode <> nil then
      try
        with 
pDevmode^ do begin
          
dmDuplex := DMDUP_VERTICAL;
          dmFields := dmFields or DM_DUPLEX;
        end;
      finally
        
// unlock devmode handle.
        
GlobalUnlock(Devmode);
      end;
    end{ If }
  
end;

 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners