DrawText文本居中显示

代码
1 CRect rectDraw; CDC dc;
2 CRect temp = rectDraw;
3 int height = dc.DrawText(_T("测试文本"), temp, DT_CENTER | DT_WORDBREAK | DT_EDITCONTROL | DT_CALCRECT);//获得文本高度
4 rectDraw.DeflateRect(0, (rectDraw.Height() - height)/2);//改变rect
5 dc.DrawText(_T("测试文本"), rectDraw, DT_CENTER | DT_WORDBREAK | DT_EDITCONTROL);//显示文本

 

posted @ 2010-03-15 10:34  山涧鸟鸣  阅读(2841)  评论(0编辑  收藏  举报