Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Calculating widths and heights of strings
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
01072336
Message ID:
01072350
Vues:
16
Hi,

You don't explain how the width of the form is supposed to relate to the length of the text.

IAC, the closest approximation for the width of the text that you can get in native VFP will be TXTWIDTH(cString)) * FONTMETRIC(6) but this is based on *average* character width and will probably end up being too short. If you need greater accuracy you should use a GetTextExtentPoint32() API call.

HTH,
Viv



>I'm creating a form programatically and want to calculate the correct values for width and height. Up to now I've been approximating with:
>
>replace width with 70*(fontsize*(LEN(expr)) )
>
>As an example, I have a label with a value of "Length of time in this position", Font:Arial Narrow - 8 point - I make the width to be 18480, but if I open the form in Designer it gets changed to 12291.667
>
>The value of FONTMETRIC(7,'Arial Narrow',8) is 13 pixels, the length of the string is 31.
>
>How do I use these values to get 12291.667?
>
>The other thing is that the height that I create for the label string is too small, and on the screen it appears to truncate descending characters, yet when I print the form it's ok.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform