Nesus
May 11th, 1999, 04:57 AM
I want to send a line of text to the printer, and have made the function found below.
and the text is send to the printer, but with the same font no mater what I put into
CreateFont(). I think that it is the same font as notepad in windows uses. But I need
to change the font and I need to change the size of the font, What will I have to do this ?
What am I missing here ?
Hope someone can help me !
void MyClass::PrintLine()
{
CPrintDialog pd(FALSE);
DOCINFO di;
memset(&di, 0, sizeof(DOCINFO));
di.cbSize = sizeof(DOCINFO);
di.lpszDocName = "Title";
pd.GetDefaults();
DEVMODE *dm = pd.GetDevMode();
CDC dc;
if(! dc.CreateDC(pd.GetDriverName(), pd.GetDeviceName(),
pd.GetPortName(), dm))
{
AfxMessageBox(_T("Can't create DC "));
}
dc.StartDoc(&di);
CFont *oldfont;
CFont xFont;
dc.SetMapMode(MM_TEXT);
xFont.CreateFont(8, //height
0, // width
0, // escapement
0, //orientation
400, //weight
FALSE, //italic
FALSE, //underline
0, //strikeout
ANSI_CHARSET,
OUT_DEVICE_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH,
_T("Courier New"));
oldfont=dc.SelectObject(&xFont);
TEXTMETRIC tm;
dc.GetTextMetrics(&tm);
int Height= tm.tmHeight + tm.tmExternalLeading;
CPrintInfo Info;
int w = dc.GetDeviceCaps(HORZRES);
int h = dc.GetDeviceCaps(VERTRES);
Info.m_rectDraw.SetRect(0,0, w, h);
OnBeginPrinting(&dc, &Info);
dc.StartPage();
dc.TextOut(0, Height*2, "This is a printer test...");
dc.SelectObject(oldfont);
dc.EndPage();
dc.EndDoc();
dc.DeleteDC();
}
Thanks for your help !
Thomas
and the text is send to the printer, but with the same font no mater what I put into
CreateFont(). I think that it is the same font as notepad in windows uses. But I need
to change the font and I need to change the size of the font, What will I have to do this ?
What am I missing here ?
Hope someone can help me !
void MyClass::PrintLine()
{
CPrintDialog pd(FALSE);
DOCINFO di;
memset(&di, 0, sizeof(DOCINFO));
di.cbSize = sizeof(DOCINFO);
di.lpszDocName = "Title";
pd.GetDefaults();
DEVMODE *dm = pd.GetDevMode();
CDC dc;
if(! dc.CreateDC(pd.GetDriverName(), pd.GetDeviceName(),
pd.GetPortName(), dm))
{
AfxMessageBox(_T("Can't create DC "));
}
dc.StartDoc(&di);
CFont *oldfont;
CFont xFont;
dc.SetMapMode(MM_TEXT);
xFont.CreateFont(8, //height
0, // width
0, // escapement
0, //orientation
400, //weight
FALSE, //italic
FALSE, //underline
0, //strikeout
ANSI_CHARSET,
OUT_DEVICE_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH,
_T("Courier New"));
oldfont=dc.SelectObject(&xFont);
TEXTMETRIC tm;
dc.GetTextMetrics(&tm);
int Height= tm.tmHeight + tm.tmExternalLeading;
CPrintInfo Info;
int w = dc.GetDeviceCaps(HORZRES);
int h = dc.GetDeviceCaps(VERTRES);
Info.m_rectDraw.SetRect(0,0, w, h);
OnBeginPrinting(&dc, &Info);
dc.StartPage();
dc.TextOut(0, Height*2, "This is a printer test...");
dc.SelectObject(oldfont);
dc.EndPage();
dc.EndDoc();
dc.DeleteDC();
}
Thanks for your help !
Thomas