G
Great
Unregistered / Unconfirmed
GUEST, unregistred user!
请看我这段代码,我明明把打印纸大小自定义成了1800*960,但用LQ1600K
打时,仍是默认的A4大小.还得要我手动设置,该如何能在程序中用Code
搞定呢?
var
PrintSZ:Boolean;
AD1,AD2,APort:array[0..255] of Char;
DevHandle:THandle;
DevModeDeviceMode;
begin
if PrintSZ then
begin
Printer.GetPrinter(AD1,AD2,APort,DevHandle);
if DevHandle = 0 then
begin
Printer.PrinterIndex :=Printer.PrinterIndex ;
Printer.GetPrinter(AD1,AD2,APort,DevHandle);
end;
if DevHandle = 0 then
begin
Application.MessageBox('打印机错误!',AppTitle,MB_OK+MB_ICONQUESTION);
Exit;
end else
begin
DevMode:=GlobalLock(DevHandle);
with DevMode^do
begin
dmFields:=dmFields or DM_PAPERLENGTH;
dmPaperLength:=960;
dmFields:=dmFields or DM_PAPERWIDTH;
dmPaperWidth:=1800;
end;
if PreCheck.Checked then
begin
PrintPreview(True);
//打印
end else
begin
PreparePrint;
Print;
DeleteAllTempFiles;
end;
end;
if Not DevHandle = 0 then
GlobalUnlock(DevHandle);
end;
打时,仍是默认的A4大小.还得要我手动设置,该如何能在程序中用Code
搞定呢?
var
PrintSZ:Boolean;
AD1,AD2,APort:array[0..255] of Char;
DevHandle:THandle;
DevModeDeviceMode;
begin
if PrintSZ then
begin
Printer.GetPrinter(AD1,AD2,APort,DevHandle);
if DevHandle = 0 then
begin
Printer.PrinterIndex :=Printer.PrinterIndex ;
Printer.GetPrinter(AD1,AD2,APort,DevHandle);
end;
if DevHandle = 0 then
begin
Application.MessageBox('打印机错误!',AppTitle,MB_OK+MB_ICONQUESTION);
Exit;
end else
begin
DevMode:=GlobalLock(DevHandle);
with DevMode^do
begin
dmFields:=dmFields or DM_PAPERLENGTH;
dmPaperLength:=960;
dmFields:=dmFields or DM_PAPERWIDTH;
dmPaperWidth:=1800;
end;
if PreCheck.Checked then
begin
PrintPreview(True);
//打印
end else
begin
PreparePrint;
Print;
DeleteAllTempFiles;
end;
end;
if Not DevHandle = 0 then
GlobalUnlock(DevHandle);
end;