Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to determine a wrapped word label's height?
Message
From
22/09/2006 17:08:46
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:
01156621
Views:
28
>>>>You are correct. My situation, however, is that I have a label in a container. The label's height does indeed get automatically determined, but I cannot get the container's height to adjust accordingly.
>>>>
>>>>In my Init of the container, I set the label's AutoSize to .T., WordWrap to .T. and Caption. Immediately after this, I set the container's height to the label's height, but it does not adjust (grow taller with the label). If I put code in the container's Resize to set its height to the label's height then things look fine. If I put code in the container's Init to call the container's Resize event, nothing happens and the label appears chopped off.
>>>>
>>>>Do you have any idea how I can have the container adjust its height to the label's height.
>>>
>>>That's easy. Just store the height of the label before you change the caption and then check it afterwards. The difference is how much you need to change the height of the caption.
>>>
>>>lnBefore = This.lblStuff.Height
>>>This.lblStuff.Caption = New Caption
>>>lnAfter = This.lblStuff.Height
>>>This.Height = This.Height+(lnAfter-lnBefore)
>>>
>>
>>Yeah, I though it was easy too. The problem that I'm having is that I set the container's height to be that of the label's wordwrapped height, but visually it does not resize from the container's Init. If I anchor the container's ends so that it stretches with the form and I put code in the resize of the container to set it's height to the label's height does it then show correctly. I need it to show this behavior on it init and not rely on resizing to correct it.
>>
>>Don't know if i've explained myself clearly here :)
>
>At what point do you change the label's caption? I'm not sure why you're trying to do this from the container's Init. I was assuming that you'd use a custom method to do this. You would call this method anytime you change the label's caption.

I'm actually changing it in a caption_assign method of the container. The assign is being done in the container init. I don't need to call it more than once (only on initialization).

What I'm actually trying to accomplish is to create a "hyperlink" control. These links all line up on the left side of the form one above the other. If a link's caption is too wide, I want it to wrap and then have the next link below the bottom of that wrapped link.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform