Back



 
Unit Get Paper Size
(* Hi ! This is a way to obtain the paper size for your printer*)
     unit Unpsj;
     interface
     uses
       Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
     Dialogs, StdCtrls, Printers, WinSpool;

     type
       TForm1 = class(TForm)
         cbbdes: TComboBox;
         procedure FormCreate(Sender: TObject);
       private
         { Private declarations }
       public
         { Public declarations }
       end;

     var
       Form1: TForm1;

     implementation

     {$R *.DFM}

     procedure TForm1.FormCreate(Sender: TObject);

     type tSize = array[0..0] of TPoint;

     var nps,i:integer;
         ap : ^tSize;
         Device, Driver, Port: Array [0..255] of Char;
         hDevMode: THandle;

     begin
        Printer.GetPrinter(Device, Driver, Port, hDevmode);
        nps:=WinSpool.DeviceCapabilities(Device, Port, DC_PAPERSIZE, nil, nil);
       GetMem(ap, nps*sizeof(TPoint));
       try
         DeviceCapabilities(Device, Port, DC_PAPERSIZE, PChar(ap), nil);//in centimeters !
        for i:=0 to nps-1 do
           cbbDes.Items.Add(FloatToStr(ap^[i].x/100)+'
     '+FloatToStr(ap^[i].y/100));
         cbbDes.ItemIndex:=0;
       finally
         if ap <> Nil then
         begin
             FreeMem(ap, nps*sizeof(TPoint));
             ap:=Nil
         end;
       end;
     end;

     end.
This unit was donated by  Cristian Fîcea 


Back
Hosted by www.Geocities.ws

1