|
{X = 2290, Y = 2970 After each run, the printer locates the Letter paper, which is very depressed. I hope everyone can give pointers! !! !! }
procedure SetPaperSize (X, Y: Integer);
var
Device: array [0..255] of char;
Driver: array [0..255] of char;
Port: array [0..255] of char;
hDMode: THandle;
PDMode: PDEVMODE;
begin
Printer.PrinterIndex: = Printer.PrinterIndex;
Printer.GetPrinter (Device, Driver, Port, hDMode);
// Get the handle value of the printer's DevMode structure, stored in hDMode
if hDMode <> 0 then begin
pDMode: = GlobalLock (hDMode);
// Get a pointer to the DevMode structure of the printer //
if pDMode <> nil then begin
pDMode ^ .dmPaperSize: = 256;
// If you want to change the current printer paper to custom, dmPaperSize must be set to 256
pDMode ^ .dmPaperLength: = X;
pDMode ^ .dmPaperWidth: = Y;
pDMode ^ .dmFields: = pDMode ^ .dmFields or DM_PAPERSIZE;
pDMode ^ .dmFields: = pDMode ^ .dmFields or DM_PAPERLENGTH;
pDMode ^ .dmFields: = pDMode ^ .dmFields or DM_PAPERWIDTH;
{The above three statements set the corresponding dmFields members. }
ResetDC (Printer.Handle, pDMode ^);
// Set the value of the printer device environment handle
GlobalUnlock (hDMode);
// The following starts to print
end;
end;
Printer.PrinterIndex: = Printer.PrinterIndex;
end; |
|