A
arm
Unregistered / Unconfirmed
GUEST, unregistred user!
上次问的,结果没有人回答,这一段程序不好使
(不必告诉我PAPERSIZE=0, 使过了不好使)
PRINTER EPSON-1800K OR EPSON 1600-K
procedure SetPaperSize(X, Y: Integer);
var
Device, Driver, Port: PChar;
HDMode: THandle;
PDMode: PDevMode;
begin
Device := StrAlloc(cchDeviceName);
Driver := StrAlloc(MAX_PATH);
Port := StrAlloc(32);
try
Printer.PrinterIndex := Printer.PrinterIndex;
Printer.GetPrinter(Device, Driver, Port, HDMode);
if HDMode<>0 then
begin
PDMode := GlobalLock(HDMode);
if PDMode =nil then
begin
with PDMode^do
begin
dmPaperSize :=256;
dmPaperWidth :=X;
dmPaperLength :=Y;
dmFields :=DM_PAPERSIZE or DM_PAPERWIDTH or DM_PAPERLENGTH;
GlobalUnlock(HDMode);
end;
Printer.PrinterIndex := Printer.PrinterIndex;
end;
end;
finally
StrDispose(Device);
StrDispose(Driver);
StrDispose(Port);
end;
end;
(不必告诉我PAPERSIZE=0, 使过了不好使)
PRINTER EPSON-1800K OR EPSON 1600-K
procedure SetPaperSize(X, Y: Integer);
var
Device, Driver, Port: PChar;
HDMode: THandle;
PDMode: PDevMode;
begin
Device := StrAlloc(cchDeviceName);
Driver := StrAlloc(MAX_PATH);
Port := StrAlloc(32);
try
Printer.PrinterIndex := Printer.PrinterIndex;
Printer.GetPrinter(Device, Driver, Port, HDMode);
if HDMode<>0 then
begin
PDMode := GlobalLock(HDMode);
if PDMode =nil then
begin
with PDMode^do
begin
dmPaperSize :=256;
dmPaperWidth :=X;
dmPaperLength :=Y;
dmFields :=DM_PAPERSIZE or DM_PAPERWIDTH or DM_PAPERLENGTH;
GlobalUnlock(HDMode);
end;
Printer.PrinterIndex := Printer.PrinterIndex;
end;
end;
finally
StrDispose(Device);
StrDispose(Driver);
StrDispose(Port);
end;
end;