General information
Category:
Coding, syntax & commands
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
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only