>>It seems that that the height and width properties of autosized labels are elusive values in the midst of updating several controls on a form. For example, if you set the label's caption, and then set autosize to true, the height and width properties don't always immediately reflect what the newly autosized height and width are. It's as if they simply aren't calculated until later, sometimes even when a wait state is imposed such as inkey(.05). This is really a hassle when you need those values _right_then_ in order to place other controls relative to the label within the same thread of code. Thanks very much for any suggestions.
>
>I am not sure, but you may try to force a "recalculation" with commands similar to this:
>
>
>with ThisForm.LblSomeMessage
> .Caption = "Some caption"
> .AutoSize = .F.
> .AutoSize = .T.
> MessageBox(transform(.Width))
>endwith
>
>
>See if it works at all. The second command might be optional. I suspect your problems appear only if you keep the .AutoSize property at .T. all the time - and trust any updating to be automatic and immediate.
It doesn't work. How can I make it work?
IF NOT EMPTY(THIS.cLabel_Caption)
LOCAL lnOriginalWidth
lnOriginalWidth = THIS.lblName.WIDTH
WITH THIS.lblName
.CAPTION = THIS.cLabel_Caption
.AUTOSIZE = .F.
.AUTOSIZE = .T.
SET STEP ON
THIS.AdjustWidth (.WIDTH - m.lnOriginalWidth)
ENDWITH
ENDIF
If it's not broken, fix it until it is.
My Blog