项目里的一个过程,希望能用
procedure custompage(iheigth, iwidth: integer);
var
adevice, adriver, aport: array[0..255] of char;
devicehandle: thandle;
devmode: pdevicemode;
begin
printer.getprinter(adevice, adriver, aport, devicehandle);
if devicehandle = 0 then
begin
printer.printerindex := printer.printerindex;
printer.getprinter(adevice, adriver, aport, devicehandle);
end;
if devicehandle = 0 then
raise exception.create('打印机错误!')
else
begin
devmode := globallock(devicehandle);
with devmode^do
begin
dmFields := dmFields or dm_papersize;
dmPaperSize := DMPAPER_USER;
dmfields := dmfields or dm_paperlength;
dmpaperlength := iheigth;
dmfields := dmfields or dm_paperwidth;
dmpaperwidth := iwidth;
end;
ResetDC(Printer.Handle, devmode^);
globallock(devicehandle);
end;
end;