Board index » cppbuilder » printing image of from

printing image of from


2004-01-26 04:40:34 PM
cppbuilder84
I am trying to print an image of a form
here is my code:
Printer()->BeginDoc();
this->PaintTo(Printer()->Handle, 10, 10);
Printer->EndDoc();
this works, but it prints a very small image.
How can I set the size of the printed image.
Thanks
 
 

Re:printing image of from

Henry wrote:
Quote
I am trying to print an image of a form
here is my code:

Printer()->BeginDoc();
this->PaintTo(Printer()->Handle, 10, 10);
Printer->EndDoc();

this works, but it prints a very small image.
How can I set the size of the printed image.
Yes, I have seen that before. Very small indeed.
The reason is that the resolution of your printer is much
higher than the resolution of your screen.
So in principle there are two solutions.
1. Tell your printer that it should pretend having
a much lower resolution. How to do that ? Never did that.
2. Untested:
Create an extra Graphics::TBitmap or a TCanvas and let your form
PaintTo() it. Then use CopyRect() to copy the bitmap/canvas to the
Printer()->Canvas. CopyRect() needs a source-rect and a destination-rect.
Make the dimensions of the destination-rect a multiple of the source-rect.
Copyrect will enlarge automatically.
Hans.
 

Re:printing image of from

Hans Galema wrote:
Quote
So in principle there are two solutions.
3. Untested: If the complete TForm is visible on your screen you could just
use the TForm Canvas property like
Printer()->Canvas->CopyRect ( destination-rect, Canvas, source-rect );
with the destination rect a multiple of the sorce-rect.
Hans.
 

{smallsort}

Re:printing image of from

Quote
I am trying to print an image of a form
here is my code:
Form.Print fails on many printers. You will also find that
many components do not print or PaintTo() correctly
(example: look for the missing text in a combobox).
You have a couple of choices.
1) You can do a screenshot (see the TI I wrote when I was at Borland
called "A better way to print a form". If your form (and its contents)
completly fit on the screen unobscured, this is a good method, with
the exception that using a single StretchDIBits call will also fail on
many printers (most likey the reason that your program does not
currently print). It requires about 2000 lines of low level support
code to get StretchDiBits to work reliably. If this is a concern
I would like to recommend our TExcellentImagePrinter product.
2) Try our TExcellentFormPrinter product. It can print the entire
contents of a form, even if the form is hidden or obscured, and
can print all the contents (even those that are scrolled from view).
More information, demo units, and documentation on TExcellentFormPrinter
and TExcellentImagePrinter can be found at:
www.code4sale.com/joehecht
Joe
--
Delphi, graphics, and printing specialist available - $35/hr
www.code4sale.com/codeit/index.htm
Joe Hecht Associates
121 Louise Drive
Crestview, FL 32536
 

Re:printing image of from

"Hans Galema" < XXXX@XXXXX.COM >wrote in message
Quote
Henry wrote:

>I am trying to print an image of a form
>here is my code:
>
>Printer()->BeginDoc();
>this->PaintTo(Printer()->Handle, 10, 10);
>Printer->EndDoc();
>
>this works, but it prints a very small image.
>How can I set the size of the printed image.

Yes, I have seen that before. Very small indeed.
The reason is that the resolution of your printer is much
higher than the resolution of your screen.

So in principle there are two solutions.
1. Tell your printer that it should pretend having
a much lower resolution. How to do that ? Never did that.

2. Untested:
Create an extra Graphics::TBitmap or a TCanvas and let your form
PaintTo() it. Then use CopyRect() to copy the bitmap/canvas to the
Printer()->Canvas. CopyRect() needs a source-rect and a destination-rect.
Make the dimensions of the destination-rect a multiple of the source-rect.
Copyrect will enlarge automatically.
Or
3. Use the Win32 API functions designed to solve this problem. Perhaps this
is what you meant in your item (1). See the "Coordinate Space and
Transformation Functions" section of the Windows API help for functions such
as:
SetWindowOrgEx
SetWindowExtEx
SetViewportOrgEx
SetViewportExtEx
OffsetViewportOrgEx
OffsetWindowOrgEx
ScaleViewportExtEx
ScaleWindowExtEx
- Dennis