MoonchildHK
Programmer
Hi All,
I am writing an IRC client. For the main message list I am using a TListBox set to LBOwnerDrawFixed. I do this because I want to display the Username first (in one color) and then the message (in another color). Everything works fine except that the ListBox has no word wrap..
When I tried to write a function to do it myself.. I ran into problems. I tried using the Canvas->TextWidth function and testing the message to be shown, starting from 1 characted only and adding more until the value = the width of the box, then splitting the message at that point to create a second entry in the ListBox etc.
This doesn't work however.. because when someone re-sizes the form, I have to re-split the message up, which means there could be more or less items in the ListBox's Items list, and thing's got really complicated :-(
Does anyone have any idea for another approach to this problem? I have got myself bogged down in horrible code.. and can't seem to find an easy way out!
I though about using a TMemo which would allow multi-line, but I can not do colors on this because there is no way overwrite the onDraw method??
I would rather avoid buying a commercial TListBox replacement which has WordWrap.
Any ideas would be gratefully received.
Thanks,
Steph
I am writing an IRC client. For the main message list I am using a TListBox set to LBOwnerDrawFixed. I do this because I want to display the Username first (in one color) and then the message (in another color). Everything works fine except that the ListBox has no word wrap..
When I tried to write a function to do it myself.. I ran into problems. I tried using the Canvas->TextWidth function and testing the message to be shown, starting from 1 characted only and adding more until the value = the width of the box, then splitting the message at that point to create a second entry in the ListBox etc.
This doesn't work however.. because when someone re-sizes the form, I have to re-split the message up, which means there could be more or less items in the ListBox's Items list, and thing's got really complicated :-(
Does anyone have any idea for another approach to this problem? I have got myself bogged down in horrible code.. and can't seem to find an easy way out!
I though about using a TMemo which would allow multi-line, but I can not do colors on this because there is no way overwrite the onDraw method??
I would rather avoid buying a commercial TListBox replacement which has WordWrap.
Any ideas would be gratefully received.
Thanks,
Steph