用TDeviceMode结构设置打印质量,墨水种类等等高级设置:
procedure TForm1.Button3Click(Sender: TObject);
var
aDevice,aDriver,aPort:array[0..255] of char;
DeviceHandle:Thandle;
DevMode
DeviceMode;// 指向TDeviceMode 结构的指针
begin
printer:=Tprinter.Create;
printer.GetPrinter(aDevice,aDriver,aPort,Devicehandle);
//首先获取Tprinter的TDeviceMode 结构的句柄
if deviceHandle=0 then
//若handle=0 ,则设备没有装入,设置printer index,再装入
begin
printer.printerIndex:=Printer.PrinterIndex;
printer.GetPrinter(aDevice,aDriver,aPort,Devicehandle);
end;
if deviceHandle=0 then
//若handle=0,则发生错误,产生异常
raise Exception.create('不能初始化TDeviceMode 结构')
else
// 否则用GlobalLock获取TDeviceMode 结构的指针
begin
DevMode:=GlobalLock(DeviceHandle);
with DevMode^do
begin
dmFields:=dmFields or //设置纸张大小
DM_PAPERSIZE or
DM_PAPERWIDTH or
DM_PAPERLENGTH;
dmPaperWidth:=你要设的纸张宽度;//dmpapersize:=Dmpaper_letter;dmpaper_A4,dmpaper_A5等
dmPaperLength:=你要设的纸张宽度;
dmFields:=dmFields or DM_ORIENTATION;
//设置打印方向
dmOrientation:=DMORIENT_PORTRAIT //纵向;DMORIENT_LANDSCAPE;
横向
dmFields :=dmFields or DMBIN_MANUAL;
//设置纸张来源
dmDefaultSource:=DMBIN_Auto;
//dmDefaultSource:=DMBIN_MANUAL;手动
dmFields :=dmFields or Dm_printQuality;
dmprintQuality:=Dmres_high;//还有dmres_medium(中),dmres_low(低),dmres_draft(草图)
dmFields :=dmFields or dm_color;
dmcolor:=dmcolor_color;//设置为彩色,dmcolor_monochrome为单色;
dmFields :=dmFields or Dm_scale;//设置打印比例
dmscale:=50;
end
end;
//else
if not DeviceHandle=0 then
GlobalUnlock(DeviceHandle);
//此处加你的代码;
end;
end;