Mr. Boy
Mr. Boy

Reputation: 63798

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)
{
...
}

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

Upvotes: 0

Views: 200

Answers (1)

Tarydon
Tarydon

Reputation: 5193

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.

Upvotes: 2

Related Questions