// JP opened flex table

Click to See Complete Forum and Search --> : Lisbox and Colors


Ayalaskin
July 11th, 2008, 12:12 AM
Hi.

I made a Listbox, and now I would like if possible, add some color to it.
I want two things.

1- Change the color of the text.

2- Change the color of the background of the itens.
Ex: The first item has a white background, the second has a gray, and so on.

I see only documents that do that with mfc, but is not my case.

Thanks.

kirants
July 11th, 2008, 12:33 AM
Handle WM_CTLCOLORLISTBOX in the parent window..
Hmm you won't be able to do it differently for different items though.

Ayalaskin
July 11th, 2008, 12:46 AM
I want to do something like this:

http://img242.imageshack.us/img242/5909/listaq1.jpg

I will load files from the disc, and some atributtes will define the text color.

The background will fallow the the default, one white, one gray.

kirants
July 11th, 2008, 12:55 AM
It seems like what you want is a list control and not a list box. A list control can have multiple columns.

Anyways, here are articles on both and am sure there are quite a few for colored controls.
Listbox articles (http://www.codeguru.com/cpp/controls/listbox/)
ListView articles (http://www.codeguru.com/cpp/controls/listview/)

Ayalaskin
July 11th, 2008, 01:06 AM
Yep, you are right, i edited, sorry for my mistake.
Whats the diference between these twos?

I checked the links, and they use strange class and functions like

LVBKIMAGE bk;
DDX_Control(pDX, IDC_LIST1, m_ColListCtrl);
dcContext.SetTextColor( crText ); // Set Text Color
dcContext.SetBkColor( crNormal ); // Set BG Color


I think these things are MFC, arent they??

Notsosuperhero
July 11th, 2008, 03:42 AM
Couldn't you have specific item color by making it owner drawn?

//JP added flex table