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

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);

你可能感兴趣的:(c++开发知识点总结)