Newsgroup: it.comp.lang.delphi
Titolo: TPrinter e la risoluzione

E' possibile modificare la risoluzione di stampa utilizzando un
ogetto Tprinter standard di delphi4????
grazie

Carina, questa! :))
non credo.
TPrinter è ad un livello di astrazione troppo elevato rispetto al drv della
stampante che è il vero responsabile della sua gestione.
Vedi invece la seguente api di winsozz nella guida sdk:
DocumentProperties
Bye
A.

 work. Anybody have an idea how to solve this problem?
Vitaly,
well, the first step is to find out which resolutions the printer
supports. You do that via Winspool.Devicecapabilities. You select one of
the available settings and the modify two fields of the printers devmode
structure accordingly.
Create a new project, drop a TRadiogroup and a TButton on it, leave the
radiogroup empty. Add handlers for the forms OnCreate event and the
buttons OnClick.
uses winspool, Printers;
{$R *.DFM}
Type
  TPrinterResolution= Record
    resx, resY: Longint;
  End;
  TPrinterResolutions = Array of TPrinterResolution;
Function GetPrinterResolutions: TPrinterResolutions;
Var
  numResolutions: Integer;
  Device, Driver, Port: Array [0..255] of Char;
  hDevMode: THandle;
Begin
  Printer.GetPrinter(Device, Driver, Port, hDevmode);
  numResolutions :=
    WinSpool.DeviceCapabilities( Device, Port, DC_ENUMRESOLUTIONS, Nil,
Nil );
  SetLength( Result, numResolutions );
  If numResolutions > 0 Then Begin
    WinSpool.DeviceCapabilities( Device, Port, DC_ENUMRESOLUTIONS,
              @Result[0], Nil );
  End;
End;
procedure TForm1.FormCreate(Sender: TObject);
var
  resarray: TPrinterResolutions;
  i: Integer;
begin
  resArray := GetPrinterResolutions;
  For i:= 0 to Length( resarray )-1 Do Begin
    // create a radiobutton for each resolution, pack the actual
    // resolution into its Tag property.
    radiogroup1.Items.add( format('%d x %d dpi',
                                  [resarray[i].resX, resarray[i].resY ]
));
    radiogroup1.Controls[i].Tag :=
      MakeLong( LoWord(resarray[i].resX), LoWord( resarray[i].resY ));
  End;
  If radiogroup1.items.count > 0 then begin
    radiogroup1.itemindex := 0;
    radiogroup1.clientheight :=
      radiogroup1.ControlCount * radiogroup1.controls[0].height;
  end
  else
    button1.enabled := false;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
  Device, Driver, Port: Array [0..255] of Char;
  hDevMode: THandle;
  pDevMode: PDeviceMode;
  dw: DWORD;
begin
  with radiogroup1 do
    dw := Controls[itemindex].Tag;
  // test print using selected resolution
  Printer.GetPrinter(Device, Driver, Port, hDevmode);
  // force reset of devmode
  Printer.SetPrinter(Device, Driver, Port, 0);
  Printer.GetPrinter(Device, Driver, Port, hDevmode);
  If hDevmode <> 0 then Begin
    pDevmode:= GlobalLock( hDevmode );
    If pDevmode <> nil Then
    try
      pDevMode^.dmPrintQuality:= LoWord( dw );
      pDevmode^.dmYResolution := HiWord( dw );
      pDevmode^.dmFields := pDevmode^.dmFields OR
                            DM_PRINTQUALITY OR
                            DM_YRESOLUTION;
    finally
      GlobalUnlock( hDevmode );
    end;
    Printer.beginDoc;
    try
      With Printer.Canvas.Font Do Begin
        Name := 'Arial';
        Size := 24;
      End;
      // print test string 1 inch from margins
      Printer.Canvas.textOut( LoWord(dw), HiWord( dw ),
                              'This is a test' );
    finally
      Printer.endDoc;
    end;
  End;
end;
Peter Below (TeamB) 
10011...@compuserve.com
)
--------------------------------
Inviato via 
http://usenet.libero.it

A proposito di Peter Below, segnalo questo utilissimo e (imho)
indispensabile file:
http://delphi.icm.edu.pl/ftp/docs/pbelow.zip
"ZIP file with 9,367 Usenet articles posted by Peter Below between July 23,
1999 and March 10, 2000"
Attenzione sono 8 Mega!
Morde.


Me la sono salvata in locale.
Molto carina.
A.

forse è sbagliato il percorso perchè non va...
"Morde" <m@m.m> ha scritto nel messaggio
news:81Z72Z0Z158Y10...@usenet.libero.it...



Ho ricontrollato, a me funziona.
http://delphi.icm.edu.pl/ftp/docs/pbelow.zip
Fa parte di Delphi Super Page
http://delphi.icm.edu.pl/
Ciao
