X
xiaofeng_cxy
Unregistered / Unconfirmed
GUEST, unregistred user!
自定义纸张大小函数如下
procedure SetPageSize(Prnt: TPrinter;
PageWidth, PageHeight: Integer);
var
Device, Driver, Port: array[0..255] of Char;
hDMode: THandle;
pDMode: PDevMode;
begin
//Prnt.PrinterIndex := Prnt.PrinterIndex;
Prnt.GetPrinter(Device, Driver, Port, hDMode);
if hDMode <> 0 then
begin
try
pDMode := GlobalLock(hDMode);
if pDMode <> nil then
begin
pDMode^.dmFields := pDMode^.dmFields or dm_PaperSize;
pDMode^.dmPaperSize := dmPaper_User;
//pDMode^.dmPaperSize := DMPAPER_FANFOLD_US;
//pDMode^.dmPaperSize := dmPaper_Last;
pDMode^.dmFields := pDMode^.dmFields or dm_PaperWidth;
pDMode^.dmPaperWidth := PageWidth;
pDMode^.dmFields := pDMode^.dmFields or dm_PaperLength;
pDMOde^.dmPaperLength := PageHeight;
//pDMode^.dmFields := pDMode^.dmFields or dmBin_Manual;
//pDMode^.dmDefaultSource := dmBin_Manual;
end;
ResetDC(Prnt.Handle, pDMode^);
finally
GlobalUnLock(hDMode);
end;
end;
//Printer.PrinterIndex := Printer.PrinterIndex;
end;
先后使用了EPSON1600K,HP LaserJet 6L,设定都是没问题的。可是在使用HP LaserJet1000、1005、1010、1100时,无论怎么设定,打印机的纸张大小都是不变的???请各位高手指教。。
在线恭候。。。。
procedure SetPageSize(Prnt: TPrinter;
PageWidth, PageHeight: Integer);
var
Device, Driver, Port: array[0..255] of Char;
hDMode: THandle;
pDMode: PDevMode;
begin
//Prnt.PrinterIndex := Prnt.PrinterIndex;
Prnt.GetPrinter(Device, Driver, Port, hDMode);
if hDMode <> 0 then
begin
try
pDMode := GlobalLock(hDMode);
if pDMode <> nil then
begin
pDMode^.dmFields := pDMode^.dmFields or dm_PaperSize;
pDMode^.dmPaperSize := dmPaper_User;
//pDMode^.dmPaperSize := DMPAPER_FANFOLD_US;
//pDMode^.dmPaperSize := dmPaper_Last;
pDMode^.dmFields := pDMode^.dmFields or dm_PaperWidth;
pDMode^.dmPaperWidth := PageWidth;
pDMode^.dmFields := pDMode^.dmFields or dm_PaperLength;
pDMOde^.dmPaperLength := PageHeight;
//pDMode^.dmFields := pDMode^.dmFields or dmBin_Manual;
//pDMode^.dmDefaultSource := dmBin_Manual;
end;
ResetDC(Prnt.Handle, pDMode^);
finally
GlobalUnLock(hDMode);
end;
end;
//Printer.PrinterIndex := Printer.PrinterIndex;
end;
先后使用了EPSON1600K,HP LaserJet 6L,设定都是没问题的。可是在使用HP LaserJet1000、1005、1010、1100时,无论怎么设定,打印机的纸张大小都是不变的???请各位高手指教。。
在线恭候。。。。