Thanks for that Joe. I've now tried using map modes instead and it looks a
bigger preview font. It 'waits' until it gets to 43.
How can I achieve this? (Microsoft Word can do it!).
"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message
Essentially, StretchBlt will do just about the worst job you can imagine
for this
(actually, it doesn't matter what you're trying to do, StretchBlt will
probably do it
wrong). I would have simply set the map mode so that the image will fill
the preview
space and use whatever I get. The nice thing about this is that the font
will be rendered
using the ClearType best-approximation instead of being uglified by
StretchBlt.
joe
On Tue, 29 Apr 2008 15:33:43 +0100, "GC" <gc@freeuk.co.uk> wrote:
Hi
I'm getting very confused with trying to draw a small print preview box.
I'm
trying to draw fonts the exact proportionate size. Because I can't show
fractional font sizes on screen, I'm trying to draw it into a memory DC
(quite big?) then StretchBlt it down onto my box (I don't mind if it's a
bit pixelly as long as it's in proportion).
This code works after a fashion but what do my values need to be? Do I
need
to set the map mode to a higher value? It comes about 1/3 size.
Thanks for any advice,
Greg Chapman
void CA4Page::OnPaint()
{
CPaintDC dc(this);
CDC memDC;
memDC.CreateCompatibleDC(&dc);
// ??? memDC.SetMapMode(MM_HIMETRIC);
int deviceRes = memDC.GetDeviceCaps(LOGPIXELSY);
CRect rect;
this->GetClientRect(&rect);
// this is roughly 210 x 297 ie a mm to a pixel
CRect memRect(0,0, 2100, 2970);
// nice big one for best resolution?
CBitmap bmp;
bmp.CreateCompatibleBitmap(&memDC, memRect.Width(), memRect.Height());
memDC.SelectObject(&bmp);
LOGFONT fontStruct;
// this fills out the struct
Utilities::FillFontStruct("Times New Roman", 0, 0, 4, fontStruct);
CString str("Hello World");
CFont font;
int pointSize = 60;
fontStruct.lfHeight = (int)-MulDiv(pointSize, deviceRes, 72);
font.CreateFontIndirect(&fontStruct);
memDC.SelectObject(&font);
memDC.DrawText(str, memRect, 0);
dc.StretchBlt(rect.left, rect.top, rect.Width(), rect.Height(),
&memDC, 0, 0, memRect.Width(), memRect.Height(),
SRCCOPY);
}
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm