Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Auto Grow an Edit Box
Message
From
26/09/2008 18:49:04
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01351074
Message ID:
01351194
Views:
24
>>>I need to have an edit box extend vertically if the user enters more text than will fit. The edit box will not have scroll bars. There will be a limit to the size and I can easily handle that part. I'm just not sure of the best way to handle the auto sizing. Is there some event that gets triggered when the text goes below the box? I thought of using memlines() but is there an easier way?
>>>TIA
>>
>>I think you're on the right track with MEMLINES() combined with FontMetric() and the Height of the editbox to see how many rows you have room for.
>>
>>Tamar
>
>Tamar,
>I'm not sure just how many of your books I have and sessions of yours that I have attended. I am sure if you don't know of a better way than MEMLINES() then that is most likely the answer.

There's also another way, but trickier. Memlines() combined with Set Memowidth To whatever you calculate as the number of characters that would fit one line in your editboox is still just an estimate, based on the average width of the characters - and that's where you may get it wrong. The average is just an average, may be quite off if you have text with a few uppercase Ms or Ws. Textwidth() may give you a better calculation, if you want to be precise - it will give you the length of the string in average characters for the given font and style - you'd only have to multiply that with the average character width. You'd have to calculate where the first line wraps, then take the rest of the string as the second line, find where it will wrap etc until you exhaust the length of the string. Can be done, but isn't really easy.

However, with MemLines(), if you just agree you may be off by one line, and try to have two blank lines below the end of text (and then if you're wrong, you may have one or three, but never run out of blank lines), then this is all simple again :).

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Reply
Map
View

Click here to load this message in the networking platform