The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Ratch on October 09, 2006, 05:03:15 AM

Title: Mulit-line colored text in listboxes
Post by: Ratch on October 09, 2006, 05:03:15 AM
To the Ineffable All,

     Does anyone know how to make colored text lines in listboxes.  It's a snap to use WM_CTLCOLORLISTBOX, and then change the text color and background.  BUT, that changes ALL the text lines in a listbox to the same color and background.  I am looking to make each line I write to a listbox a different color and background.  Is that possible?  Ratch
Title: Re: Mulit-line colored text in listboxes
Post by: PBrennick on October 09, 2006, 06:06:32 AM
Ratch,
Yes, you can do that by putting the listbox control onto a richedit window. It is probablly overkill but I acquired an addressbook application from someon, forgot who.  There were 3 rows of columns per entry so the author decided to change background colors for each entry. I will post it, if you like. The zip is 35,164 bytes.

Paul
Title: Re: Mulit-line colored text in listboxes
Post by: japheth on October 09, 2006, 07:33:11 AM

My suggestion is: use a listview with 1 column to emulate the listbox. With the listview, use the CUSTOMDRAW feature.
Title: Re: Mulit-line colored text in listboxes
Post by: Tedd on October 09, 2006, 10:53:52 AM
Listbox has OWNERDRAW styles (LBS_OWNERDRAWFIXED, LBS_OWNERDRAWVARIABLE) -- pick one and go from there :wink
I'd go with fixed.
Title: Re: Mulit-line colored text in listboxes
Post by: Ratch on October 10, 2006, 12:38:46 AM
To the Ineffable All,

     Listbox with LBS_OWNERDRAWFIXED style works great.  Capture WM_DRAWITEM and use TextOut or DrawItem.  Thanks to all and especially Tedd.  Ratch