T
tl_lyq
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.Button4Click(Sender: TObject);
var
BMP: TBitMap;
SR, DR: TRect;
P: TPoint;
printer:tprinter;
dlg: TPrinterSetupDialog;
pointX,PointY:integer;
PointScale,PrintStep,printW:integer;
begin
dlg := TPrinterSetupDialog.Create(nil);
if dlg.Execute then
begin
BMP := TBitMap.Create;
BMP.Width := ScrollBox1.Width;
BMP.Height := ScrollBox1.Height;
P := ScrollBox1.ClientToParent(Point(0, 0), Self);
SR := Rect(P.X, P.Y, BMP.Width, BMP.Height);
DR := Rect(0, 0, BMP.Width, BMP.Height);
BMP.Canvas.CopyRect(DR, Canvas, SR);
printer:=tprinter.Create;
printer.Canvas.Font.Name:='宋体';
printer.canvas.Font.Size:=11;
PointX:=Trunc(GetDeviceCaps(Printer.Handle,LOGPIXELSX)/2.54);
pointY:=Trunc(GetDeviceCaps(Printer.Handle,LOGPIXELSY)/2.54);
PointScale:=Trunc(GetDeviceCaps(Printer.Handle,LOGPIXELSX)/Screen.PixelsPerInch+0.5);
Printer.begin
Doc;
self.PrintScale :=poProportional;
Bitblt(printer.Canvas.Handle, 0, 0, bmp.Width*PointX, bmp.Height*PointY,
bmp.Canvas.Handle, 0, 0, srcCopy);
Printer.EndDoc;
Application.MessageBox('正在打印,请等待。','提示:',32);
dlg.Free;
BMP.Free;
end;
var
BMP: TBitMap;
SR, DR: TRect;
P: TPoint;
printer:tprinter;
dlg: TPrinterSetupDialog;
pointX,PointY:integer;
PointScale,PrintStep,printW:integer;
begin
dlg := TPrinterSetupDialog.Create(nil);
if dlg.Execute then
begin
BMP := TBitMap.Create;
BMP.Width := ScrollBox1.Width;
BMP.Height := ScrollBox1.Height;
P := ScrollBox1.ClientToParent(Point(0, 0), Self);
SR := Rect(P.X, P.Y, BMP.Width, BMP.Height);
DR := Rect(0, 0, BMP.Width, BMP.Height);
BMP.Canvas.CopyRect(DR, Canvas, SR);
printer:=tprinter.Create;
printer.Canvas.Font.Name:='宋体';
printer.canvas.Font.Size:=11;
PointX:=Trunc(GetDeviceCaps(Printer.Handle,LOGPIXELSX)/2.54);
pointY:=Trunc(GetDeviceCaps(Printer.Handle,LOGPIXELSY)/2.54);
PointScale:=Trunc(GetDeviceCaps(Printer.Handle,LOGPIXELSX)/Screen.PixelsPerInch+0.5);
Printer.begin
Doc;
self.PrintScale :=poProportional;
Bitblt(printer.Canvas.Handle, 0, 0, bmp.Width*PointX, bmp.Height*PointY,
bmp.Canvas.Handle, 0, 0, srcCopy);
Printer.EndDoc;
Application.MessageBox('正在打印,请等待。','提示:',32);
dlg.Free;
BMP.Free;
end;