Link to home
Start Free TrialLog in
Avatar of sasabunetic
sasabunetic

asked on

List Box color

Hi!

Check next code:

  CListBox   *pCLB;
  char       szB [256];

  pCLB = (CListBox *) GetDlgItem (IDC_TESTPLACE_LIST);  // get List-Box
  sprintf (szB, "%s", MessageText);
  if (szB[0] != 0) {
    pCLB->InsertString(-1, &szB[0]);
  }

Text is now displayed only in black color. How can I set different text colors in CListBox?

Thanks
Sasa
Avatar of caner_elci
caner_elci

You have to use owner draw items.. Set ListBox's OWNERDRAW style and use CListBox::MeasureItem, CListBox::DrawItem pair to draw your own items.. So you can set any color or font in your list box..
A featured sample can be found at : http://www.codeproject.com/combobox/xlistbox.asp
ASKER CERTIFIED SOLUTION
Avatar of Daniel Junges
Daniel Junges
Flag of Brazil image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial