look at

GetTextExtentPoint32()

to find the exact length of any given string on any given Device Context.

Call then use the SIZE.cx param and your client rect (or the update rect in the PAINTSTRUCT.rcPaint)

Another way is to use DrawText() as it allows more formatting control.