Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to determine a wrapped word label's height?
Message
From
25/09/2006 16:28:31
Mike Sue-Ping
Cambridge, Ontario, Canada
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01155729
Message ID:
01157084
Views:
33
>>>I think the problem might be that you're assigning the caption before the container is done with its Init in that case. IOW, the container hasn't been instantiated yet, so you can't change its height. You can check this by seeing what you get back from THIS.HEIGHT in the container's Init before you try to assign the caption.
>>
>>Ok, I tried assigning the caption in a custom method of the form. By that time, the containers' Inits are complete correct? Still a no go :(
>>
>
>I don't know. It depends when you call that custom method.
>
>>Interestingly, check this out. I've put a container on a form. In that container I put a label with Autosize=.T., Wordwrap=.T., Caption="Test". I sized the label's width to 80 (narrow enough to force a wordwrap to occur when I set the caption later). In the form's Init, I set the label's Caption="This is a long caption to test the wordwrap feature".
>>
>>From the debugger, when I step thru the form's init to check the label's height, it starts out at 17, the default. After the caption is changed to the longer one, the height is still 17. It does not seem to know that the wordwrap took place. Bug?
>
>Maybe. It seems that's the case with anything you call before the form is painted. For example, if I create a form with a label that has all the properties set to make it stretch, and I set a label's caption to "Test", then display the height in the Init of the label, it's 17. If I make the label's caption a lot longer in the form's Init and then display the label's height, it's still 17. If I move that code to the form's Activate method, then I get the correct label height.

Sorry, forgot to mention that I called my custom method in the form's init believing that all contained objects's are already initialized by then.

As for the label test that you did. I'm finding something very strange going on here. If the label sits directly on the form, it works as you found (the form's activate method must be used to get the correct height). However, if I put the label in a container it doesn't work the same. In my form's activate I have
thisform.container1.height = thisform.container1.label1.height
I've already set the label caption to a very long string in the form's init. When I run the form, the container's height is as if the label's caption is only one line tall, i.e. it did not work. If I put a SET STEP ON in the form's activate and then step thru the code, everything is as expected, i.e. the container's height grows to accomodate the label's wordwrap. This is just Sick.

Update...I found that if I put a DOEVENTS FORCE as the first line in the form's activate event, things look fine. Go figure.
Previous
Reply
Map
View

Click here to load this message in the networking platform