![]() |
This page explains how to draw Unicode text strings with
TextOut.
The first step is to specify a Unicode font. Declare
In the header file: CFont m_font;
In the
void OnInitialUpdate()
{
LOGFONT lf;
memset(&lf,0,sizeof(lf));
lf.lfHeight = 16;
strcpy(lf.lfFaceName,"Lucida Sans Unicode");
if (!m_font.CreateFontIndirect(&lf))
{
MessageBox("Unable to set font",MB_OK);
}
CView::OnInitialUpdate();
}
The format of the pDC->TextOut(int x, int y, CString str); | ||
|
The following code shows the actual drawing section of the Unicode string. The Unicode font should be selected prior to the drawing of the Unicode text strings on screen.
void OnDraw(CDC* pDC)
{
pDC->SelectObject(m_font);
int x,y;
CString str;
// set the coordinate (x,y) and a Unicode string to str
pDC->TextOut(x,y,str);
}
|