RSS订阅 | 匿名投稿
您的位置:网站首页 > 打印 > 正文

delphi 设置打印机 纸张大小! 也可以获取纸张大小

作者:admin 来源:未知 日期:2010/4/26 22:51:13 人气: 标签:

Var
aDevice: array[0..CCHDEVICENAME-1] of Char;
aDriver: array[0..MAX_PATH-1] of Char;
aPort: array[0..31] of Char;
hDevMode: THandle;
pDevMode: PDeviceMode;
begin
// 获取打印机DeviceMode的句柄

Printer.GetPrinter(aDevice, aDriver, aPort, hDevMode);
if hDevMode <> 0 then
begin
// 获取指向DeviceMode的指针
printer.PrinterIndex:=printer.PrinterIndex;
pDevMode := GlobalLock(hDevMode);
if pDevMode <> nil then
begin
pDevMode^.dmPaperSize := DMPAPER_USER; //自定义纸张
pDevMode^.dmPaperLength := 250; //纸长你可用变量获得纸张的长、宽。
pDevMode^.dmPaperWidth := 400; //纸宽
pDevMode^.dmFields := pDevMode^.dmFields or DM_PAPERSIZE;
pDevMode^.dmFields := pDevMode^.dmFields or DM_PAPERLENGTH;
pDevMode^.dmFields := pDevMode^.dmFields or DM_PAPERWIDTH;
ResetDC(Printer.Handle, pDevMode^);
GlobalUnlock(hDevMode);
end;
end;
读完这篇文章后,您心情如何?
0
0
0
0
0
0
0
0
本文网址: