Windows or MFC, I'm not sure which.. whatever the code below represents.

I want to print text to a label printer. I'd like to center the text in
the label and increase the font size over whatever the default is. I
don't understand the RECT thing or how to calculate coordinates or use
fonts. The code below works and it's pretty simple, I'd like to stay
with this scheme if possible (I have similar code elsewhere in the app).
I copied it from MSDN, I think.

Can someone explain how to use a standard Windows font like Arial 12 and
center the text, or point me to a tutorial?

Thanks
---------------

CDC cdc;
HDC hdc;
CPrintDialog dlg(TRUE); // Windows Printer Dialog class
CString formattedpage;

if (dlg.DoModal() == IDOK)
{
// Create a printer device context (DC)
// based on the information
// selected from the Print dialog.
hdc = dlg.CreatePrinterDC();
ASSERT(hdc);
// Attach Device Context object to handle
cdc.Attach(hdc);
cdc.StartDoc("Pan Label"); // begin a new print job
}
else
{
// abort print
}

RECT rect = {0,0,0,0}; // RECT structure for page
cdc.DrawText(formattedpage,&rect,DT_CALCRECT);
cdc.StartPage();

formattedpage.Format("STUFF TO PRINT");
cdc.DrawText(formattedpage,&rect,DT_NOCLIP);
cdc.EndPage();
cdc.EndDoc();

Re: understanding Windows printing by Feng

Feng
Mon Jun 05 16:49:24 CDT 2006

Check for functions like CreateFont, CreateFontIndirect, SelectObject,
SetTextAlign

Generally speaking, DrawText is designed for simple text drawing on user
interface, not printing.

If you want to know more about GDI, read
http://www.amazon.com/gp/product/0130869856

--
Feng Yuan [MSFT] http://blogs.msdn.com/fyuan

"Dave Cullen" <nospam@mail.com> wrote in message
news:448490D4.8C603F6C@mail.com...
> Can someone explain how to use a standard Windows font like Arial 12 and
> center the text, or point me to a tutorial?