home *** CD-ROM | disk | FTP | other *** search
/ Delphi 4 Bible / Delphi_4_Bible_Tom_Swan_IDG_Books_1998.iso / source / PrintMisc / Print3.pas < prev   
Pascal/Delphi Source File  |  1998-03-10  |  715b  |  28 lines

  1. procedure TForm1.Button1Click(Sender: TObject);
  2. var
  3.   P: TPicture;
  4.   ScaleX, ScaleY: Integer;
  5.   R: TRect;
  6. begin
  7.   P := TPicture.Create;
  8.   try
  9.   // Modify the pathname string in the following statement
  10.   // to load any .bmp, .ico, or metafile:
  11.     P.LoadFromFile('D:\Delphi 4 Bible\Source\Data\Sample.bmp');
  12.     Printer.BeginDoc;
  13.     with Printer do
  14.     try
  15.       ScaleX :=
  16.         GetDeviceCaps(Handle, logPixelsX) div PixelsPerInch;
  17.       ScaleY :=
  18.         GetDeviceCaps(Handle, logPixelsY) div PixelsPerInch;
  19.       R := Rect(0, 0, P.Width * ScaleX, P.Height * ScaleY);
  20.       Canvas.StretchDraw(R, P.Graphic);
  21.     finally
  22.       Printer.EndDoc;
  23.     end;
  24.   finally
  25.     P.Free;
  26.   end;
  27. end;
  28.