Re: Centering label in a form by Tim
Tim
Thu Feb 09 08:21:34 CST 2006
Thanks, Bernard.
I have now made this work, but needed a bit more than you said. The
width of the label must cover the whole width of the form - it seems to
center the caption in the label width, not in the form. And you must
give it enough height for the largest font or you truncate the text.
This also means that you must leave enough space below the label for the
full height because otherwise it will prevent another label in the same
space being seen. So it can interfere with the layout.
Regards
Tim
In article <u3YIGAXLGHA.3984@TK2MSFTNGP14.phx.gbl>, Bernhard Sander
<fuchs@individsoft.de> writes
>Hi Tim
>
>> At present I put the label's left property to 70, through trial and
>>error, which is about OK with the alignment property on the default
>>of 0 (left). If, instead of this, I set the alignment property to 2
>>(center) the caption appears almost off the form to the left.
>Maybe you try this:
>- put a label on your form
>- set AutoSize to .F.
>- make it as large as is necessary for the largest message you want to display
>- set Alignment to 2 - center
>- shift the label to the position on the form where you want to display
>your messages.
>
>Now your messages are centered horizontally even if you change font size.
>
>If you also want it vertically centered, there is more work to do.
>Then you have to subclass the label class, add methods Width_Assign and
>Height_Assign and put appropriate code into these two methods.
>
>BTW, form.AutoCenter has only effect when the form is loaded. Later
>changes of size doesn't re-center the form.
>
>Regards
>Bernhard Sander
--
Tim Hobson