您的位置:首页 > 其它

计算gdi 函数DrawString绘制的字符串象素长度和高度

2014-03-26 09:43 267 查看
CMemoryDC dcMem(&dc);

Gdiplus::Graphics graphics(dcMem.m_hDC);

LOGFONT lfFont = CFunctions::GetDefaultFont();

lfFont.lfHeight = -12;

lfFont.lfWeight |= FW_BOLD;

Font font1(dcMem.GetSafeHdc(), &lfFont);

SolidBrush brush1((ARGB)Color::Black);

RectF rtGdiplus;//计算消息主题的宽度

graphics.MeasureString(wName, wName.GetLength(), &font1, PointF(nLINE_LEFT+45, nTop+10), &rtGdiplus);

int nwith=rtGdiplus.Width;

MessageBox.Show(rtGdiplus.Width);

MessageBox.Show(rtGdiplus.Height);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: