Article View: borland.public.cppbuilder.nativeapi
Article #1799Re: Screen v/s Printer Fonts
From: Bob Gonder
Date: Sat, 09 Jun 2007 23:17
Date: Sat, 09 Jun 2007 23:17
95 lines
4222 bytes
4222 bytes
JD wrote:
>I'm at a bit of a loss with how to proceed with a print preview.
Do you have the BDS or TCE?
Searching in the BDS help for preview, the #1 hit is for VC++ MFC
When selecting a printer font, an apropriate screen font is chosen to
match it.
This makes sense.
More under Print Preview Architecture
There are also several EnumFont* functions to help confuse matters.
Something along this line might work
Except display the BMP instead of saving to file.
If you have fancier printing requirements, the DC is available for
other functions as well.
struct CPBstruct{
HDC printerDC;
HFONT printerFont;
unsigned long printerDy;
unsigned long printerDx;
Graphics::TBitmap * bmp;
};
extern "C"
CPBstruct* __declspec(dllexport) WINAPI CreatePrinterBitmap(
DWORD paperheightX100,
DWORD paperwidthX100,
DWORD topmarginX100,
DWORD leftmarginX100,
DWORD vertdpi,
DWORD horizdpi,
DWORD rows,
DWORD cols,
char orientation,
bool mono )
{
CPBstruct*c = new CPBstruct;
c->bmp = new Graphics::TBitmap();
c->bmp->Monochrome = mono;
unsigned long height = paperheightX100 - topmarginX100;
unsigned long width = paperwidthX100 - leftmarginX100;
c->bmp->Height = (vertdpi * height) / 100;
c->bmp->Width = (horizdpi * width) / 100;
c->printerDC = c->bmp->Canvas->Handle;
c->printerDy = c->bmp->Height / rows;
c->printerDx = c->bmp->Width / cols;
c->printerFont= CreateFont(
c->printerDy-2, c->printerDx-2,
0, // angle
0, // base-
FW_THIN, // font weight
FALSE, // italic attrib
FALSE, // underline att
FALSE, // strikeout att
OEM_CHARSET, // character set identif
OUT_TT_PRECIS, // output precision
CLIP_DEFAULT_PRECIS, // clipping precision
DRAFT_QUALITY, // output quality
FIXED_PITCH+FF_MODERN, // pitch and family
"Courier New" // pointer to typeface name
);
return c;
}
extern "C"
void __declspec(dllexport) WINAPI PrintOnPrinterBitmap(
CPBstruct* c,
unsigned long y, unsigned long x,
char*str, unsigned long z)
{
SetTextAlign( c->printerDC, TA_LEFT+TA_TOP+TA_NOUPDATECP );
SetBkMode( c->printerDC, TRANSPARENT );
ExtTextOut( c->printerDC, c->printerDx*x, c->printerDy*y,
0,
(RECT*)NULL,
str,
z,
(int*)NULL );
}
extern "C"
void __declspec(dllexport) WINAPI SavePrinterBitmap(
CPBstruct* c,
char*filename )
{
c->bmp->SaveToFile( filename );
}
Technical Details
Message-ID:
<8gam639hm3q5cc226ng1lt7efr0b7e1i97@4ax.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<466adf52$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,be0d896b55cafce X-Google-Attributes: gid10cc67,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: Bob Gonder <notbg@notmindspring.invalid> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Screen v/s Printer Fonts Date: Sat, 09 Jun 2007 16:17:30 -0700 Organization: MindSpring Enterprises, Inc. Reply-To: notbg@notmindspring.invalid Message-ID: <8gam639hm3q5cc226ng1lt7efr0b7e1i97@4ax.com> References: <466adf52$1@newsgroups.borland.com> X-Newsreader: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 71.0.32.39 X-Trace: newsgroups.borland.com 1181431046 71.0.32.39 (9 Jun 2007 16:17:26 -0700) Lines: 96 Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail