Try this rountine. Just assign FormHandle to whatever form you are printing.

uses printers;

procedure TForm1.Button1Click(Sender: TObject);
var
  FormHandle: THandle;
  wDC: HDC;
  SrcRect: TRect;
  Bmp: TBitmap;
begin
  Bmp := TBitmap.Create;
  with Bmp do
  try
    FormHandle := Self.Handle;
    SetForegroundWindow(FormHandle);
    RedrawWindow(FormHandle, nil, 0, RDW_INVALIDATE+RDW_UPDATENOW);
    GetWindowRect(FormHandle, SrcRect);
    Width := SrcRect.Right-SrcRect.Left;
    Height := SrcRect.Bottom-SrcRect.Top;
    wDC := GetWindowDC(FormHandle);
    BitBlt(Canvas.Handle, 0, 0, Width, Height, wDC, 0, 0, SRCCOPY);
    with Printer do
    begin
      BeginDoc;
      Canvas.Draw((PageWidth - Bmp.Width) div 2,
                  (PageHeight - Bmp.Height) div 2, Bmp);
      EndDoc;
    end;
  finally
    Bmp.Free;
  end;

end;

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
Behalf Of David O'Brien
Sent: Tuesday, March 06, 2001 9:13 AM
To: Multiple recipients of list delphi
Subject: RE: [DUG]: TForm.Print


Problem is, it is failing on all printers (lasers, plotters and inkjets), at
least one that has 80M of ram, and we use for GIS work, i.e very large
graphics.

Any ideas what to try to solve this?
Any other automated way to print the current form?

Dave.

-----Original Message-----
From: Steve Peacocke [mailto:[EMAIL PROTECTED]]
Sent: Thursday, 1 March 2001 17:10
To: Multiple recipients of list delphi
Subject: Re: [DUG]: TForm.Print


At 09:44 am 1/03/01 +1300, David O'Brien said:
>Does anyone know why the TForm.Print function prints blank pages when the
>form width is over a certain size, or how to get around the problem? Using
>D5.

One possability is that the form graphic is too much for the memory in the
printer. This may be a printer problem rather than a Delphi problem.

Steve

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"

Reply via email to