Article View: borland.public.cppbuilder.nativeapi
Article #14764Re: Print settings
From: JD
Date: Fri, 01 Aug 2003 21:22
Date: Fri, 01 Aug 2003 21:22
33 lines
2034 bytes
2034 bytes
"Marco" <lazzarom@hotmail.it> wrote:
> this is the code i use to print:
I see that you took it verbatim from the help file. Did you
also see that you can use PaintTo to send it to a bitmap
instead?
Once you have it painted to the bitmap, you can use StretchDraw
to print the image to a Rect that you can define anywhere on
the Printer Canvas. If the Rect is smaller than the image, it
will be scaled down and if it's larger, it will stretch it to
fill the Rect. Just be careful with the Rect dimentions so
they are proportionally the same as the image or the image
will look distorted.
The following example needs some error checking and is
untested. It will print the PageControl starting at (0,0) and
ending at (200,200).
Graphics::TBitmap *pImage = new Graphics::TBitmap();
for( int i = Start; i <= Stop; ++i )
{
pImage->Height = PageControl->Pages[i]->Height;
pImage->Width = PageControl->Pages[i]->Width;
pImage->Canvas.Lock();
PageControl->Pages[i]->PaintTo( pImage->Handle, 0, 0 );
Printer()->Canvas->StretchDraw( TRect(0, 0, 200, 200), pImage );
pImage->Canvas.Unlock();
}
delete pImage;
~ JD
Technical Details
Message-ID:
<3f2ada0b$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!newshosting.com!news-xfer2.atl.newshosting.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailReferences:
<3f2a6df8$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,d5de15b490a744a2 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-08-01 14:28:01 PST From: "JD" <nospam@nospam.com> Sender: "JD" <nospam@nospam.com> Reply-To: "JD" <nospam@nospam.com> Subject: Re: Print settings Newsgroups: borland.public.cppbuilder.nativeapi X-User-Info: 172.149.88.108 172.149.88.108 References: <3f2a6df8$1@newsgroups.borland.com> NNTP-Posting-Host: 207.105.83.65 Message-ID: <3f2ada0b$1@newsgroups.borland.com> Date: 1 Aug 2003 14:22:19 -0700 X-Trace: newsgroups.borland.com 1059772939 207.105.83.65 (1 Aug 2003 14:22:19 -0700) Lines: 34 Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!newshosting.com!news-xfer2.atl.newshosting.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail