Board index » delphi » Printing the Paintbox

Printing the Paintbox


2007-02-27 08:03:10 AM
delphi194
Can someone show me some code on how to print objects on the paintbox? The
paintbox in my application has some objects scrolled off the screen,
therefore I cannot capture the screen into a bitmap.
 
 

Re:Printing the Paintbox

Our TExcellentFormPrinter product can print the full PaintBox
contained on a Form or ScrollBox control to any size you wish,
including pre-scaled to fit a page, or even printed across multiple
pages.
TExcellentFormPrinter canbe found here:
www.code4sale.com/joehecht/index.htm
Joe
--
Delphi, graphics, and printing specialist available - $35/hr
www.code4sale.com/codeit/index.htm
Joe Hecht
"George Kuascha" <XXXX@XXXXX.COM>writes news:XXXX@XXXXX.COM...
Quote
Can someone show me some code on how to print objects on the paintbox? The
paintbox in my application has some objects scrolled off the screen,
therefore I cannot capture the screen into a bitmap.


 

Re:Printing the Paintbox

George Kuascha writes:
Quote
Can someone show me some code on how to print objects on the
paintbox? The paintbox in my application has some objects scrolled
off the screen, therefore I cannot capture the screen into a bitmap.
Move the code you now have in the paintboxes OnPaint event to a method
that has two parameters: aCanvas: TCanvas; aRect: TRect. In the OnPaint
handler you call this method with the paintbox.Canvas and the
paintbox.ClientRect as parameters. Of course you need to recode the
drawing stuff to remove any references to the paintbox object, the
drawing code should only use the passed parameters.
You can now call the same method using the printer.canvas and a rect
constructed from the printer.pagewidths and pageheight. You can also
call it with a bitmap.canvas or a metafilecanvas.
There is a fly in this ointment, however: the paintbox canvas and the
printer canvas will have very different resolution (pixels or dots per
inch). If you draw using device units (pixel coordinates) the output on
the printer canvas will be much smaller than you would like it. The
solution to this dilemma is to use device-independent units for
positions and sizes, e.g. twips (1/1440 inch = 1/20 point) or 1/100 mm.
You can either handle the conversions between these units and the
device units yourself (simply math but cumbersome, use the
GetDeviceCaps API function with the canvas.handle and LOGPIXELS_X/Y to
get the resolution in dots per inch), or you can use the SetMapMode API
function to define a mapping that will make Windows do the conversion
for you. YOu have to set the canvas.font.pixelsperinch value to the
proper value (1440 for twips, for example) to get the correct font
sizes when you set the font.size property (which uses points as units).
--
Peter Below (TeamB)
Don't be a vampire (slash7.com/pages/vampires),
use the newsgroup archives :
www.tamaracka.com/search.htm
groups.google.com
www.prolix.be