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