Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Dynamic Sizing of a Read-Only Editbox
Message
From
04/08/1997 22:10:49
 
 
To
04/08/1997 11:57:20
Jp Steffen
Leadership Data Services
Des Moines, Iowa, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00043003
Message ID:
00043152
Views:
68
Can you use a textbox instead of an editbox? I think you do, or at least you can fake a read-only editbox with a textbox if really want an editbox. :)

So, use a textbox with Autosize = .t. and WordWrap = .t. If WordWrap is true, Autosize acts on the vertical, not on the horizontal. So, VFP will calculate the Height (you can take textbox's height!) for you and it will also display it correctly. Just tried it and it works like a charm. This is a cute feature. I didn't know it until now!

Vlad

>Paul,
>
>Using memlines is a good idea, I will try that. Can't use scroll bars - this is a wizard style interview engine that stores instruction text and control class names in a database and then instantiates both the message and the control container as the user moves from one page of the interview to the next. I never know how much depth the message box (ie text box) will need or how much vertical space the controls will need and I want to display all the text, all at once, with no blank space between the instructions and the control. So I have to make sure the edit box does not cross over on top of the controls. I want it all - Paul, I want it all! It actually works pretty good - but it could be better. Maybe MEMLINES will help. Thanks
>
>JP
>
>>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
Map
View

Click here to load this message in the networking platform