Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Vertically centre text in a static control

1,970 views
Skip to first unread message

Paul N

unread,
Mar 22, 2012, 6:06:31 PM3/22/12
to
I have a dialog box which has some push buttons, and some static
controls next to them to describe what they do. I've discovered that,
if I make the static controls tall enough and don't select any
options, then the text will automatically wrap onto a new line. This
is good.

However, the text can change, with one version of the wording long
enough to need a second line and another version not. And if I make
the box big enough for two lines and positioned so that they will be
centred with respect to the button, then when there is only a single
line it looks too high.

In researching this I've discovered SS_CENTERIMAGE which (despite the
name) seems to vertically centre the text. And still appears to leave
it horizontally left justified, which is also good. But it seems to
stop the text wrapping - if the text is long I just get a single line
with the end of the text missing. This is bad.

Is there a way to vertically centre the text while still allowing it
to wrap?

Thanks.
Paul.

David Lowndes

unread,
Mar 23, 2012, 5:39:46 AM3/23/12
to
>In researching this I've discovered SS_CENTERIMAGE which (despite the
>name) seems to vertically centre the text. And still appears to leave
>it horizontally left justified, which is also good. But it seems to
>stop the text wrapping - if the text is long I just get a single line
>with the end of the text missing.

The documentation for SS_CENTERIMAGE does say:

" If the static control contains a single line of text, the text is
centered vertically in the client area of the control."

>Is there a way to vertically centre the text while still allowing it
>to wrap?

I'm not aware of an easy way (that's not to say there isn't one). You
might have to do it yourself as an owner drawn control.

Dave

Paul N

unread,
Mar 25, 2012, 3:49:42 PM3/25/12
to
Thanks for that, Dave. I've also just tried putting a "\n" into the
text to manually split it into two lines, but that didn't work either.
I think the easiest way is going to be to adjust the wording so that
the wording for a particular button always has the same number of
lines.

Paul.

0 new messages