开发者

MFC: Render string in multiple formats

开发者 https://www.devze.com 2022-12-16 07:45 出处:网络
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)

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

精彩评论

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