What is the correct way to autosize a Static control?

Viewed 5711

I want to adjust a Static control's size to its content size, so I need to calculate the size of its text content first. I found a way to use GetTextExtentPoint32 to calculate the size, but I need to set the DC's font to the same as the control's font first. Is there a better way to do this? I've set the Static control's font once, I think maybe I don't need to set the DC's font the second time.

What is the best way to calculate the size of a Static control's text content? And is there a better way to autosize the Static control?

3 Answers
Related