Board index » delphi » changing printer parameters

changing printer parameters

Hi all,
My application has to change the default feeder, or make multiple page
printing. Those kind of operation are only avalaible from a dialog box,
and my users want it to be automatiquely done.
Does someone know wich api to use to access the specific parameters of a
printer. (The parameters of a printer change with the printer, so you
can't have a classical structure)

 

Re:changing printer parameters


On Thu, 31 Jul 1997 18:37:56 +0200, Samuel Stammbach

Quote
<Samuel.Stammb...@studi.epfl.ch> wrote:
>Hi all,
>My application has to change the default feeder, or make multiple page
>printing. Those kind of operation are only avalaible from a dialog box,
>and my users want it to be automatiquely done.
>Does someone know wich api to use to access the specific parameters of a
>printer. (The parameters of a printer change with the printer, so you
>can't have a classical structure)

Samuel,

the actual API call is CreateDC which will get you a pointer to a
DEVMODE structure (TDEVMODE in Delphi 1.0); look at the GetPrinter
method help for info. To use it, the following code (I sorta copied it
from somebody else's post, didn't test it) should help:

var
  PrintDevice, PrintDriver, PrintPort: array [0..255] of Char;
  hDMode: THandle;
  pDMode : PDevMode;
begin
  Printer.GetPrinter(PrintDevice, PrintDriver, PrintPort, hDMode);
  if hDMode <> 0 then
  begin
    pDMode := GlobalLock(hDMode);
    try
      with pDMode^ do
      begin
{ some printer parameter settings:  }
        dmOrientation := DMORIENT_PORTRAIT;
        dmFields := dmFields or DM_ORIENTATION;
        dmPaperSize := DMPAPER_A4;
        dmFields := dmFields or DM_PAPERSIZE;
        dmCopies := 2;
        dmFields := dmFields or DM_COPIES;
      end;
   finally
      GlobalUnlock(hDMode);
    end;
  end;

hth
David

------------------
David A. Schweizer

iec ProGAMMA, The Netherlands
d.a.schwei...@gamma.rug.nl

Other Threads