B
blues hu
Unregistered / Unconfirmed
GUEST, unregistred user!
以下是我的过程,怎样把本次设置的改变应用到打印机中
即在程序中改变打印机的设置
procedure setprinter;//设置打印机
type
Tpname=array[0..63]of char;
Tpnames=array[0..0]of Tpname;
var
papernamesointer;
i,rslt:integer;
device,driver,port:array[0..255]of char;
adevmode,PrnHd:Thandle;
devmodedevicemode;
a3support:boolean;
PrnInfo : PPrinterInfo1;
pcbNeeded,PDevModeBytes : DWORD;
begin
printer.PrinterIndex :=printer.PrinterIndex ;
printer.GetPrinter(device,driver,port,adevmode);
rslt:=devicecapabilitiesa(device,port,dc_papernames,nil,nil);
if rslt>0 then
begin
getmem(papernames,rslt*64);
try
if devicecapabilitiesa(device,port,dc_papernames,papernames,nil)=-1 then
raise exception.Create('deccap error');
for i:=0 to rslt - 1do
if strpas(Tpnames(papernames^))='A3' then
a3support:=true;
finally
freemem(papernames,rslt*64);
end;
end;
if a3support then
begin
printer.PrinterIndex :=printer.PrinterIndex ;
printer.GetPrinter(device,driver,port,adevmode);
if adevmode<>0 then
begin
devmode:=globallock(adevmode);
try
devmode^.dmFields:=devmode^.dmFields or dm_papersize or dm_orientation;
devmode^.dmpapersize:=DMPAPER_A3;
devmode^.dmOrientation :=dmorient_portrait;
// devmode^.dmpapersize:=DMORIENT_LANDSCAPE;
Printer.SetPrinter(Device,Driver,Port,aDevmode);
finally
globalunlock(adevmode);
end;
end
else
raise exception.Create('打印机初始化错误!');
printer.begin
Doc ;
printer.Canvas.TextOut(5,6,'24efhsdghasjhgjkf');
printer.EndDoc ;
end;
end;
即在程序中改变打印机的设置
procedure setprinter;//设置打印机
type
Tpname=array[0..63]of char;
Tpnames=array[0..0]of Tpname;
var
papernamesointer;
i,rslt:integer;
device,driver,port:array[0..255]of char;
adevmode,PrnHd:Thandle;
devmodedevicemode;
a3support:boolean;
PrnInfo : PPrinterInfo1;
pcbNeeded,PDevModeBytes : DWORD;
begin
printer.PrinterIndex :=printer.PrinterIndex ;
printer.GetPrinter(device,driver,port,adevmode);
rslt:=devicecapabilitiesa(device,port,dc_papernames,nil,nil);
if rslt>0 then
begin
getmem(papernames,rslt*64);
try
if devicecapabilitiesa(device,port,dc_papernames,papernames,nil)=-1 then
raise exception.Create('deccap error');
for i:=0 to rslt - 1do
if strpas(Tpnames(papernames^))='A3' then
a3support:=true;
finally
freemem(papernames,rslt*64);
end;
end;
if a3support then
begin
printer.PrinterIndex :=printer.PrinterIndex ;
printer.GetPrinter(device,driver,port,adevmode);
if adevmode<>0 then
begin
devmode:=globallock(adevmode);
try
devmode^.dmFields:=devmode^.dmFields or dm_papersize or dm_orientation;
devmode^.dmpapersize:=DMPAPER_A3;
devmode^.dmOrientation :=dmorient_portrait;
// devmode^.dmpapersize:=DMORIENT_LANDSCAPE;
Printer.SetPrinter(Device,Driver,Port,aDevmode);
finally
globalunlock(adevmode);
end;
end
else
raise exception.Create('打印机初始化错误!');
printer.begin
Doc ;
printer.Canvas.TextOut(5,6,'24efhsdghasjhgjkf');
printer.EndDoc ;
end;
end;