 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Jmosquer@ Guest
|
Posted: Wed Apr 05, 2006 2:03 pm Post subject: Print Form |
|
|
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
|
Posted: Wed Apr 05, 2006 7:03 pm Post subject: Re: Print Form |
|
|
Hi,
copy from screen.canvas to bitmap.canvas
Regards
Heiner |
|
| Back to top |
|
 |
Jmosquer@ Guest
|
Posted: Wed Apr 05, 2006 8:03 pm Post subject: Re: Print Form |
|
|
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
|
Posted: Wed Apr 05, 2006 8:03 pm Post subject: Re: Print Form |
|
|
| 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
|
Posted: Thu Apr 06, 2006 6:03 am Post subject: Re: Print Form |
|
|
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
|
Posted: Mon Apr 10, 2006 6:03 am Post subject: Re: Print Form |
|
|
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 |
|
 |
|
|
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
|
|