Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using Fontmetric/Textwidth to manually calculate wordwra
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Vista
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01426686
Message ID:
01426710
Vues:
69
This message has been marked as a message which has helped to the initial question of the thread.
Hi Geraldo,

> ListBox have AutoHideScrollbar porperty that I want to use. EditBox don't have AutoHideScrollbar property.

Which makes the formatting code a bit more complicated. There is no even that fires when the Scrollbar is shown or hidden. You need to know in advance when the scrollbar will appear, or not. That means, you might need to recalculate the size twice.

>So I need to insert text string in ListBox and if the text is greater than ListBox.Width, I need to insert into new line.

The approach is basically this:

- You start with an empty string for the line.
- Search for the next blank or line feed. Cut this part off the text, but don't add it to the line buffer yet
- Determine the width for line buffer+alltrim(newWord).
- If the total width is less than the listbox width
- add newWord (without Alltrim) to the line buffer
- if next character is a line feed, print line and clear buffer
- otherwise
- if the buffer is empty, add newWord to the buffer and clear newWord
.- print line
- initialize buffer with newWord (if not already cleared)
- repeat at step 2

The width of a string is
FONTMETRIC(6,cFontName,nFontsize)*TXTWIDTH(cStr,cFontName,nFontSize)
When you print the line make sure to use RTRIM(buffer)
--
Christof
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform