本文整理自网络,侵删。
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;
相关阅读 >>
Delphi 条件编译语法 $ifdef $else $endif
更多相关阅读请进入《Delphi》频道 >>