Quick question:
For several reasons, in my IF template, I've substituted labels for list boxes. Which meant I'd have to find out a way to word-wrap (and to properly display "[" as paragraphs, but that's done, no prob). I did, but I'm not really happy with it.
Basically, when writing to the listbox, I use the following check:
desc.Length*LETTERWIDTH>lstRoomDesc.Width
"desc" is the string passed to the function this is on, i.e., it's the full string. It gets truncated as each line is added to the listbox.
LETTERWIDTH is #defined as 4. It's a guess-timate for the width of the average character in the font I'm using (default font).
lstRoomDesc.Width, as it suggests, is the width of the listbox.
Having a resizeable listbox doesn't make it any easier on myself... anyway.
The character 'i' is one pixel wide. The character 'L' is more than that. I have no idea how many pixels are in ' '. So most often, the line either wraps before reaching the end of the listbox (quite a bit before it does, in fact), or continues a bit past the end of the listbox. Fine-tuning is impossible - the difference between 3 and 4 is quite big, and I'm pretty sure I can't use a float... can I?
Basically, is there a better way to do this? I'm guessing not, but asking never hurt...