I didn’t find this in the documentation for the static standard window so I figured I’d put it out in my blog in the hopes that someone else won’t get stuck on this problem.
The Windows “static” control has a number of styles that control how the control draws text. They can be extremely useful when controlling how the control lays out text.
I recently had to write code that draws the name of an audio endpoint into a relatively size constrained static text control. No problem, right?
Well what happens if the name of the endpoint is somewhat longer? No problem, the SS_CENTER style will wrap the words.
But sometimes the endpoint name is longer than “Headset Microphone”. In fact the user can set the endpoint name to anything they want.
Long Headset M
Uck, that looks ugly.
Fortunately the static control has an option SS_WORDELLIPSIS that looks like it should be perfect for me:
“Windows NT or later: Truncates any word that does not fit in the rectangle and adds ellipses.”
That sounds exactly like what I want. But when I added SS_WORDELLIPSIS, I got:
| Long He…
Hold on, that’s not right, what happened to the rest of my text?
After a bit of digging, I finally figured out what was going on (by trial an error removing all the various static control styles I specified).
It turns out that this behavior is by design, even though I couldn’t find any documentation of it. If you specify any of the ellipsis styles for the static control, the control becomes a single line control. The only way I’ve found to fix this is to make the static control an owner draw control and use the DrawThemeText (or DrawText) API specifying the DT_WORDBREAK | DT_ENDELLIPSIS option.
I’ve filed a documentation bug to ensure that this gets fixed sometime in the near future.
 I’ve approximated what was going on in my UI with HTML tables, this is a rough approximation to show more-or-less what was going on.
ETA: Thanks to Drew and Lindseth for reviewing this.
Edit: Fixed word wrap in edit control.