Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Dynamic Sizing of a Read-Only Editbox
Message
De
03/08/1997 17:51:40
 
 
À
03/08/1997 14:05:53
Jp Steffen
Leadership Data Services
Des Moines, Iowa, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00043003
Message ID:
00043006
Vues:
62
Instead of looking for chr(10), use memlines() FoxPro function (works for any char variable, not only memo). You also must take care of word wrapping. Basically: the number of lines * the height of one line. Sounds easy, isn't it? I know it's not only that. :)

Can't you always use the maximum available area and have scroll bars? Is it too easy/simple?

>Hey!
>
>Does anybody have a good solution to dynamically calculating the Height property of an edit box based on the Font, Font Size, Width property and number of characters in a memo which is passed as the control source to the edit box? Here is what I have been using:
>
>Where 'lcMsg' is my memo string & 475 pixels is the fixed edit box width
>also if there
>
>
>lnHeight = FONTMETRIC(1,"ARIAL",10) + FONTMETRIC(4,"ARIAL",10)
>lnChrWidth = LEN(lcMsg) + (.15 * LEN(lcMsg))
>thisform.cEditBox1.Height = ;
> ( CEILING((lnChrWidth * FONTMETRIC(6,"ARIAL",10))/475) + IIF(CHR(10) $ lcMsg,1,0) ) * lnHeight
>
>
>* .15 X LEN(lcMsg) gives me an addtional 15% character count to compensate for string lengths on the narrow side.
>* " IIF(CHR(10) $ lcMsg,1,0)" credits the string with an extra line because a CR adds only one character but a whole new line.
>
>Actually, this works fairly well, but as the value of len(lcMsg) goes up or if there is more that one (1) CR in the string the height property becomes more and more inaccurate. Generally my problem is the height property grows two much and inserts blank vertical space that other objects on the page could be using.
>
>Any Ideas?
>
>TIA JP
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform