VC竖排文字

来源:百度知道 编辑:UC知道 时间:2024/06/30 13:11:47
现在编辑一个程序需要在MFC的用户窗口上输出竖排的文字,怎么弄啊?不知道用什么函数实现!谢谢!

在OnPaint函数加这个:

CPaintDC dc(this);
CFont vertFont;
CRect rect;
CString strText=" HEllo WoRLD! "; //文本内容
GetClientRect(rect);
//字体
vertFont.CreateFont(16, 0, 900, 900, FW_BOLD,
0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH, "Arial");
CFont *pOldFont = dc.SelectObject(&vertFont);
COLORREF oldColor = dc.GetTextColor();
dc.SetTextColor(RGB(255, 0, 255)); //文本颜色
dc.SetBkMode(TRANSPARENT);
dc.TextOut(rect.left+2, rect.bottom-4, strText); //文本起始位置
dc.SetTextColor(oldColor);
dc.SelectObject(pOldFont);

DrawText,仔细看MSDN说明。
不过中文输出会很难看

看看建立字体函数 CreateFont