procedure TMainForm.N11Click(Sender: TObject);<br>var<br> ScaleX,ScaleY :Integer;<br> R :TRect;<br>begin<br> if Printer.Printers.Count=0 then<br> begin<br> ShowMessage('请首先安装打印机');<br> Exit; //跳出N11Click<br> end;<br> if not MainPrintDialog.Execute then Exit<br> else<br> begin<br> with Printer do<br> begin<br> BeginDoc;<br> ScaleX :=GetDeviceCaps(Handle,LogPixelsX) div PixelsPerInch;<br> ScaleY :=GetDeviceCaps(Handle,LogPixelsY) div PixelsPerInch;<br> R :=Rect(0,0,MDIChildForm.MainImage.Width*ScaleX,MDIChildForm.MainImage.Height*ScaleY);<br> Canvas.StretchDraw(R,MDIChildForm.MainImage.Picture.Graphic);<br> EndDoc;<br> end;<br> end;<br>end;<br>记得添加Printers单元。