Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Dynamic Sizing of a Read-Only Editbox
Message
From
03/08/1997 14:05:53
Jp Steffen
Leadership Data Services
Des Moines, Iowa, United States
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Dynamic Sizing of a Read-Only Editbox
Miscellaneous
Thread ID:
00043003
Message ID:
00043003
Views:
136
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
Next
Reply
Map
View

Click here to load this message in the networking platform