BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Print Form

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics
View previous topic :: View next topic  
Author Message
Jmosquer@
Guest





PostPosted: Wed Apr 05, 2006 2:03 pm    Post subject: Print Form Reply with quote



Delphi 5
Report Builder


Hi, my APP has a form with many components (Panels, TPaintox, Buttons).
I need to capture a screen portion to print.

I think something like this

- Capture a screen portion
- Save to clipboard or save to file
- Inside report, load o paste image
- Ready to print

How can i do that ?

Regards,
Back to top
Heinrich Wolf
Guest





PostPosted: Wed Apr 05, 2006 7:03 pm    Post subject: Re: Print Form Reply with quote



Hi,

copy from screen.canvas to bitmap.canvas

Regards
Heiner
Back to top
Jmosquer@
Guest





PostPosted: Wed Apr 05, 2006 8:03 pm    Post subject: Re: Print Form Reply with quote



sorry, but how can i do that ?

Region copy is a TRect ?

"Heinrich Wolf" <invalid (AT) invalid (DOT) invalid> escribió en el mensaje
news:443400a2$1 (AT) newsgroups (DOT) borland.com...
Quote:
Hi,

copy from screen.canvas to bitmap.canvas

Regards
Heiner
Back to top
Bill Edwards
Guest





PostPosted: Wed Apr 05, 2006 8:03 pm    Post subject: Re: Print Form Reply with quote

Quote:
How can i do that ?

Food for thought:


procedure SaveForegroundImageAsJPEG( const Filename: String );
// uses JPEG ...
var
WindowCanvas : TCanvas;
Bitmap : TBitmap;
JPEGImage : TJPEGImage;
begin
WindowCanvas := TCanvas.Create;
Bitmap := TBitmap.Create;
JPEGImage := TJPEGImage.Create;
try
WindowCanvas.Handle := GetWindowDC( GetForegroundWindow );

Bitmap.Width := WindowCanvas.ClipRect.Right;
Bitmap.Height := WindowCanvas.ClipRect.Bottom;

With Bitmap.Canvas do
CopyRect( ClipRect, WindowCanvas, ClipRect );

JPEGImage.Assign( Bitmap );

JPEGImage.SaveToFile( Filename );
finally
WindowCanvas.Free;
Bitmap.Free;
JPEGImage.Free;
end;
end;

procedure SaveDesktopImageAsJPEG( const Filename: String );
// uses JPEG ...
var
DesktopCanvas : TCanvas;
Bitmap : TBitmap;
JPEGImage : TJPEGImage;
begin
DesktopCanvas := TCanvas.Create;
Bitmap := TBitmap.Create;
JPEGImage := TJPEGImage.Create;
try
DesktopCanvas.Handle := GetWindowDC( GetDeskTopWindow );

Bitmap.Width := DesktopCanvas.ClipRect.Right;
Bitmap.Height := DesktopCanvas.ClipRect.Bottom;

With Bitmap.Canvas do
CopyRect( ClipRect, DesktopCanvas, ClipRect );

JPEGImage.Assign( Bitmap );

JPEGImage.SaveToFile( Filename );
finally
DesktopCanvas.Free;
Bitmap.Free;
JPEGImage.Free;
end;
end;
Back to top
Heinrich Wolf
Guest





PostPosted: Thu Apr 06, 2006 6:03 am    Post subject: Re: Print Form Reply with quote

Hi,

procedure TMainForm.ButtonClick(Sender: TObject);
var Bitmap : tBitmap;
begin
Bitmap := tBitmap.Create;
Bitmap.Width := ClientWidth;
Bitmap.Height := ClientHeight;
Bitmap.Canvas.CopyRect(Rect(0, 0, Bitmap.Width, Bitmap.Height),
Canvas, Rect(0, 0, ClientWidth, ClientHeight));
Bitmap.SaveToFile('C:\tmp.bmp');
Bitmap.Free;
end;

I'm sorry: It is not Screen.Canvas, but {Mainform.}Canvas

Regards
Heiner
Back to top
Joe C. Hecht
Guest





PostPosted: Mon Apr 10, 2006 6:03 am    Post subject: Re: Print Form Reply with quote

If you need more than just a screenshot (for example, the portions that are scrolled from view)
take a look at our TExcellentFormPrinter at:

http://www.code4sale.com/joehecht/index.htm

Whatever you do, dont use Form.Print. It fails on many printers, and also
fails to print many components (for example, comboboxes will be missing text).

Joe
--
Delphi, graphics, and printing specialist available - $35/hr
http://www.code4sale.com/codeit/index.htm
Joe Hecht Associates
121 Louise Drive
Crestview, FL 32536
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.