Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Label doesn't move to correct position
Message
 
 
To
24/02/2010 17:46:54
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01450840
Message ID:
01450869
Views:
52
I use
.visible = .visible
instead.

>You are setting Left, but Width doesn't get handled correctly unless you make it non-default
.Width = .Width
>
>>I have a form where I'm "drawing" things on the fly. Mostly, it all works really well. But I have one case that's baffling me.
>>
>>In this situation, based on a user request, I create a container (everything here is at least two subclasses below VFP base classes) and then add bunch of other containers to it, based on some data. The containers that I'm adding contain, among other things, a label. The container has a property (nDisplayPort) with an assign method. The assign method converts the value of that property to character and assigns it to the label's Caption:
>>
>>
>>LPARAMETERS vNewVal
>>*To do: Modify this routine for the Assign method
>>THIS.nDisplayPort = m.vNewVal
>>
>>* Propogate to label
>>This.lblPortNum.Caption = TRANSFORM(This.nDisplayPort)
>>
>>
>> The Caption also has an assign method, which among other things, repositions the label within the container based on the length of the caption:
>>
>>
>>LPARAMETERS vNewVal
>>
>>DODEFAULT(m.vNewVal)
>>
>>* Modified 15-February-2010 by TEG
>>* Move left, if necessary
>>
>>LOCAL nWidth, cFontStyle
>>
>>IF LEN(This.Caption) > 1
>>	cFontStyle = IIF(This.FontBold, "B", "") + IIF(This.FontItalic, "I", "")
>>	nWidth = LEN(This.Caption) * FONTMETRIC(6, This.FontName, This.FontSize, m.cFontStyle)
>>	* Figure out where to put it
>>	This.Left = (This.Parent.Width - m.nWidth)/2
>>ENDIF 
>>
>>
>>The label's AutoSize property is true, so that should be all I need to do to center the label within the container.
>>
>>It works, sort of. Most of the time, when I test, any two-digit labels (there's nothing more than 2 digits) start out to the left of where they should be and when the form repaints (which happens based on other things going on in the app), shift to the right into the right position.
>>
>>What makes it weird is that when I take a look with the Debugger, the label's Left is exactly what it should be and, in fact, if I change the value to the same thing in the Debugger, the label shifts to the right position. I've tried adding code to "kick" it into place by resetting .Left to itself, but it doesn't work. (I've tried a series of points in the code, longer and longer after where I originally set it.)
>>
>>Anybody have any suggestions?
>>
>>Tamar
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform