开发者

MFC: Render string in multiple formats

Using a CDC & CDC::DrawText(Ex), I want to render a string with a sub-string in bold

e.g:

void renderText(CDC *pDC,CString &str,int boldStart,int boldEnd)
{
...
}
  • example: renderText(pDC,"Test String",0,3) -> Test String
  • example: renderText(pDC,"Test String",5,-1) -> Test Stri开发者_运维问答ng

I assume I'll make 3 CDC::DrawText calls, but how do I know the positions to draw each string?


Use CDC::GetTextExtent to get the number of pixels each piece of the string will take up, and adjust the points you pass into CDC::DrawText accordingly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜