2010-01-12 24 views
0

使用CDC &çDC::DrawText(Ex),我想渲染用粗体MFC:渲染字符串以多种格式

子字符串的字符串如:

void renderText(CDC *pDC,CString &str,int boldStart,int boldEnd) 
{ 
... 
} 
  • 例如:renderText(PDC , “测试 字符串”,0,3) - >测试字符串
  • 例如:renderText(PDC, “测试 字符串”,5,-1) - >测试字符串

我假设我会做3 CDC::DrawText调用,但是如何知道绘制每个字符串的位置?

回答

2

使用CDC :: GetTextExtent获取每个字符串占用的像素数量,并相应地调整传入CDC :: DrawText的点。

+0

非常感谢,正是我需要的。 – 2010-01-14 10:40:09