In VFP6. I have a label in a form and I change the caption and font
after an action. Is there any way to center the revised caption, similar
to the autocenter property of a form ? There does not seem to be a
similar property for a label.
--
Tim Hobson

Re: Centering label in a form by Dennis

Dennis
Tue Feb 07 14:35:01 CST 2006

Hi Tim,

Take a look at the label's Alignment property.

Dennis Longfellow

"Tim Hobson" <Tim@tjhobson.demon.co.uk> wrote in message
news:CsJ19iCA4K6DFwEN@tjhobson.demon.co.uk...
> In VFP6. I have a label in a form and I change the caption and font after
> an action. Is there any way to center the revised caption, similar to the
> autocenter property of a form ? There does not seem to be a similar
> property for a label.
> --
> Tim Hobson



Re: Centering label in a form by Tim

Tim
Wed Feb 08 13:25:30 CST 2006

Thanks, Dennis, but this does not seem to do it. 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.

Hentzenwerke's guide says that the alignment property for a label does
not do anything if autocenter is T, which it is. But if I set it to F
the label is not wide enough for the revised caption.

The workings of this property seem most odd.

Has anyone actually tried this ?

Tim

In article <uHPE5XCLGHA.2416@TK2MSFTNGP15.phx.gbl>, Dennis Longfellow
<drlongfellowxxx@xxx.directrac.com> writes
>Hi Tim,
>
>Take a look at the label's Alignment property.
>
>Dennis Longfellow
>
>"Tim Hobson" <Tim@tjhobson.demon.co.uk> wrote in message
>news:CsJ19iCA4K6DFwEN@tjhobson.demon.co.uk...
>> In VFP6. I have a label in a form and I change the caption and font after
>> an action. Is there any way to center the revised caption, similar to the
>> autocenter property of a form ? There does not seem to be a similar
>> property for a label.
>> --
>> Tim Hobson
>
>

--
Tim Hobson

Re: Centering label in a form by Bernhard

Bernhard
Thu Feb 09 05:57:35 CST 2006

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

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