Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Creating an autosizing editbox
Message
De
22/03/2005 14:26:40
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00998157
Message ID:
00998205
Vues:
42
Hi David,

Yes, I've been experimenting with adding/subtracting constants from 1 to 16 from my editbox width to account for any unseen margins that VFP may be applying. Still no consistency in my results.

In general, my approach has been to subtract 6 from the width of the editbox to determine the actual display width of the control. I arrived at 6 via: 2 * ( .BorderStyle + .Margin )

But like I said, subtracting or adding 0 ... 16 to/from the editbox width doesn't seem to fix the problem with all fonts and font sizes. By font I mean the default MS True Type or MS Open Type fonts that ship with XP Pro.

Any ideas appreciated!

Malcolm

>Malcolm,
>
>Are you sure you are taking things like Margin, BorderStyle and SpecialEffect into account? Each of these and maybe one tor two others take away from space available for the text with respect to the edt.Width.
>
>>VFP 8, 9: I've been trying to create an autosizing editbox - in other words an editbox that adjusts its height so that it shows the full contents of its Value without the need for a scrollbar and without showing any unnecessary blank lines. The reason I'm looking for an autosizing editbox (and not a label) is that I have text to display that may be longer than the 254 char limit of a label's caption. I also want the user to be able to highlight text within this control for copy to the clipboard.
>>
>>I've tried 3 approaches to calculate the vertical space required to display a wordwrapped line of text:
>>
>>- Win32 API DrawText()/CreateFont()
>>
>>- VFP's old "?" output command in conjunction with fontmetric() and row()
>>
>>- Manually parsing the text to be displayed and using fontmetric(), textwidth() to calculate word/line breaks and manually calculating text height
>>
>>All 3 of the above techniques produce IDENTICAL text height results. Unfortunately, the VFP editbox uses a "mysterious" word wrapping algorithm that wraps text slightly differently than the above techniques.
>>
>>So, is there anyway using the native VFP editbox that I can determine how many lines it needs to fully display a block of text without using scrollbars? Or is there some property I can set that will make the editbox wrap text consistent with one of the above techniques for calculating text height?
Malcolm Greene
Brooks-Durham
mgreene@bdurham.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform