Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Resize control to field size in form designer
Message
From
09/12/1999 11:31:55
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00301020
Message ID:
00301057
Views:
31
Having a bit of a tinker with the builder mechanism using the aselobj() function to populate an array from the form designer. I have missed out the builder parameters and the splitting of the control source etc. but this may do the trick.


LPARAMETER ...

LOCAL lnCount
LOCAL lnLength
LOCAL lnFieldWidth

*!* Create array of control names.
lnObjCount = aselobj(laSelected)

*!* A zero count indicates no objects selected.
if lnObjects > 0
for lnCount = 1 TO lnObjects
if laSelected[lnCount].BaseClass $ "textbox"
lcField = FieldFromControlSource()
lcAlias = AliasFromControlSource()

lnLength = fsize(lcField, lcAlias)

*!* Work out the width based on the current font.
lnFieldWidth = txtWidth(replicate("w", lnLength), ;
laSelected[lnCount].FontName, laSelected[lnCount].FontSize) * ;
fontmetric(6, laSelected[lnCount].FontName, laSelected ;
[lnCount].FontSize) + 2

laSelected[lnCount].Width = lnFieldWidth
endif
endfor
endif


Or something along those lines :-)
Previous
Reply
Map
View

Click here to load this message in the networking platform