Delphi 设置打印纸张大小,手动设置打印纸的长度和宽度,自定义纸张。相关代码:
procedure TForm1.SetPaperSize(cx, cy: Integer);
var
a,b,c: array[0..255]of char;
bb: Cardinal;
ee: PDEVMODE;
begin
printer.PrinterIndex := printer.PrinterIndex;
printer.GetPrinter(a,b,c,bb);
ee:= GlobalLock(bb);
ee^.dmPaperSize := DMPAPER_USER;
ee^.dmPaperLength := cy*10;
ee^.dmPaperWidth := cx*10;
ee^.dmFields :=ee^.dmFields or DM_PAPERSIZE or
DM_PAPERWIDTH or
DM_PAPERLENGTH;
ee^.dmFields := ee^.dmFields or DMBIN_MANUAL;
ee^.dmDefaultSource :=DMBIN_MANUAL;
GlobalUnlock(bb);
printer.PrinterIndex := printer.PrinterIndex;
end;
1