W
ww10326
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure Tfrmrep_base.ToolButton2Click(Sender: TObject);
var
aDevice,aDriver,aPort:array[0..255] of char;
DeviceHandle:Thandle;
DevModeDeviceMode
begin
if printer.printers.count>0 then
begin
// printer:=Tprinter.Create;
printer.Refresh;
printer.GetPrinter(aDevice,aDriver,aPort,Devicehandle);
if deviceHandle=0 then
begin
printer.printerIndex:=Printer.PrinterIndex;
printer.GetPrinter(aDevice,aDriver,aPort,Devicehandle);
end;
if deviceHandle=0 then
raise Exception.create('错误')
else begin
DevMode:=GlobalLock(DeviceHandle);
with DevMode^ do
begin
dmFields:=dmFields or DM_PAPERSIZE or DM_FORMNAME;
dmPaperSize:=DMPAPER_A3;
// dmPaperLength:=2097;
// dmPaperWidth:=4200;
end;
end;//else
if not DeviceHandle=0 then
GlobalUnlock(DeviceHandle);
Printer.PrinterIndex := Printer.PrinterIndex;
end
else
begin
application.messagebox('dd',mb_ok);
end;
上面程序执行完以后打印机默认还是A4纸,没起作用,哪位帮忙看看问题出在哪里?
var
aDevice,aDriver,aPort:array[0..255] of char;
DeviceHandle:Thandle;
DevModeDeviceMode
begin
if printer.printers.count>0 then
begin
// printer:=Tprinter.Create;
printer.Refresh;
printer.GetPrinter(aDevice,aDriver,aPort,Devicehandle);
if deviceHandle=0 then
begin
printer.printerIndex:=Printer.PrinterIndex;
printer.GetPrinter(aDevice,aDriver,aPort,Devicehandle);
end;
if deviceHandle=0 then
raise Exception.create('错误')
else begin
DevMode:=GlobalLock(DeviceHandle);
with DevMode^ do
begin
dmFields:=dmFields or DM_PAPERSIZE or DM_FORMNAME;
dmPaperSize:=DMPAPER_A3;
// dmPaperLength:=2097;
// dmPaperWidth:=4200;
end;
end;//else
if not DeviceHandle=0 then
GlobalUnlock(DeviceHandle);
Printer.PrinterIndex := Printer.PrinterIndex;
end
else
begin
application.messagebox('dd',mb_ok);
end;
上面程序执行完以后打印机默认还是A4纸,没起作用,哪位帮忙看看问题出在哪里?