Z
zh.ys
Unregistered / Unconfirmed
GUEST, unregistred user!
在我的程序中画里一个表格,在表格的不同位置上用不同的字体写上了不少字,
原先是在A3纸上输出,后想在A4上也输出出来,想用DEVMODE中的dmScale来解决,
但是在打印机上输出的时候,A4纸上打印时没有缩小比例打印,不知道为什么?
部分程序如下:
procedure TA3A4Form.Button2Click(Sender: TObject);
var
ADevice,ADriver,APort:string;
ADeviceMode:THandle;
DevModeDeviceMode;
begin
try
SetLength(ADevice,255);
SetLength(ADriver,255);
SetLength(APort,255);
if ADeviceMode=0 then
begin
Printer.PrinterIndex:=Printer.PrinterIndex;
Printer.GetPrinter(Pchar(ADevice),PChar(ADriver),Pchar(APort),ADeviceMode);
end;
if ADeviceMode<>0 then
begin
DevMode:=GlobalLock(ADeviceMode);
try
if A3A4Form.RadioButton1.Checked then
begin
DevMode^.dmFields:=DevMode^.dmFields or DM_PaperSize;
DevMode^.dmPaperSize:=DMPAPER_A3;
end;
if A3A4Form.RadioButton2.Checked then
begin
DevMode^.dmFields:=DevMode^.dmFields or DM_PaperSize;
DevMode^.dmPaperSize:=DMPAPER_A4;
DevMode^.dmFields:=DevMode^.dmFields or DM_SCALE;
DevMode^.dmScale:=70;
end;
finally
Printer.SetPrinter(Pchar(ADevice),PChar(ADriver),Pchar(APort),ADeviceMode);
GlobalUnlock(ADeviceMode);
end;
end;
finally
end;
//----------------------------------------------------------
Printer.PrinterIndex := Printer.PrinterIndex;
//-------------------------------------------------------------------------------
close;
end;
=====================================================================
procedure TForm1.N11Click(Sender: TObject);
begin
PreviewScale:=1;
//------------------------------------------------------------------------------------
Printer.Orientation:=poLandScape;
// PrinterSetupDialog1.Execute;
if MessageDlg('确定要打印吗?',mtConfirmation,[mbYes,mbNo],0) = mrYes then
begin
A3A4Form.showmodal;
try
Printer.begin
Doc;
try
with Printerdo
begin
Canvas.Pen.Width:=2;
Canvas.Pen.Color := clblack;
Canvas.Pen.Mode := pmCopy;
Canvas.Pen.Style :=psSolid;
Canvas.Rectangle(Form1.x1 div PreviewScale,Form1.y1 div PreviewScale,Form1.x23 div PreviewScale,Form1.y36 div PreviewScale);
//--------------------------------------------------------------------------------
Canvas.Font.PixelsPerInch:=Printer.Canvas.Font.PixelsPerInch;
//--------------------------------------------------------------------------------
canvas.Pen.Width:=1;
canvas.Pen.Color:= clblack;
canvas.Pen.Mode:= pmCopy;
canvas.Pen.Style:= pssolid;
//横线----------------------------------------------------------------------------
canvas.MoveTo(Form1.x1 div PreviewScale,form1.y2 div PreviewScale);
canvas.LineTo(Form1.x23 div PreviewScale,form1.y2 div PreviewScale);
....
原先是在A3纸上输出,后想在A4上也输出出来,想用DEVMODE中的dmScale来解决,
但是在打印机上输出的时候,A4纸上打印时没有缩小比例打印,不知道为什么?
部分程序如下:
procedure TA3A4Form.Button2Click(Sender: TObject);
var
ADevice,ADriver,APort:string;
ADeviceMode:THandle;
DevModeDeviceMode;
begin
try
SetLength(ADevice,255);
SetLength(ADriver,255);
SetLength(APort,255);
if ADeviceMode=0 then
begin
Printer.PrinterIndex:=Printer.PrinterIndex;
Printer.GetPrinter(Pchar(ADevice),PChar(ADriver),Pchar(APort),ADeviceMode);
end;
if ADeviceMode<>0 then
begin
DevMode:=GlobalLock(ADeviceMode);
try
if A3A4Form.RadioButton1.Checked then
begin
DevMode^.dmFields:=DevMode^.dmFields or DM_PaperSize;
DevMode^.dmPaperSize:=DMPAPER_A3;
end;
if A3A4Form.RadioButton2.Checked then
begin
DevMode^.dmFields:=DevMode^.dmFields or DM_PaperSize;
DevMode^.dmPaperSize:=DMPAPER_A4;
DevMode^.dmFields:=DevMode^.dmFields or DM_SCALE;
DevMode^.dmScale:=70;
end;
finally
Printer.SetPrinter(Pchar(ADevice),PChar(ADriver),Pchar(APort),ADeviceMode);
GlobalUnlock(ADeviceMode);
end;
end;
finally
end;
//----------------------------------------------------------
Printer.PrinterIndex := Printer.PrinterIndex;
//-------------------------------------------------------------------------------
close;
end;
=====================================================================
procedure TForm1.N11Click(Sender: TObject);
begin
PreviewScale:=1;
//------------------------------------------------------------------------------------
Printer.Orientation:=poLandScape;
// PrinterSetupDialog1.Execute;
if MessageDlg('确定要打印吗?',mtConfirmation,[mbYes,mbNo],0) = mrYes then
begin
A3A4Form.showmodal;
try
Printer.begin
Doc;
try
with Printerdo
begin
Canvas.Pen.Width:=2;
Canvas.Pen.Color := clblack;
Canvas.Pen.Mode := pmCopy;
Canvas.Pen.Style :=psSolid;
Canvas.Rectangle(Form1.x1 div PreviewScale,Form1.y1 div PreviewScale,Form1.x23 div PreviewScale,Form1.y36 div PreviewScale);
//--------------------------------------------------------------------------------
Canvas.Font.PixelsPerInch:=Printer.Canvas.Font.PixelsPerInch;
//--------------------------------------------------------------------------------
canvas.Pen.Width:=1;
canvas.Pen.Color:= clblack;
canvas.Pen.Mode:= pmCopy;
canvas.Pen.Style:= pssolid;
//横线----------------------------------------------------------------------------
canvas.MoveTo(Form1.x1 div PreviewScale,form1.y2 div PreviewScale);
canvas.LineTo(Form1.x23 div PreviewScale,form1.y2 div PreviewScale);
....