Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

listbox font color change

Status
Not open for further replies.

prpleprncs

Programmer
Jul 12, 2002
14
VG
How do you change the the color of the font in a listbox?
 
If you're using MFC, just derive a class from CListBox and handle the WM_SETFONT message in that derived class. Then, wherever you need to use the color change, just change CListBox to CMyColoredListBox.

If you're not using MFC, it gets more complicated. You'll need to look into SetWindowLong(), using the index GWL_WNDPROC.
 
Hang on a second, what am I thinking here???

You can probably just send it the WM_SETFONT message, like this:

Code:
SendMessage(hwndListBox,WM_SETFONT,(WPARAM)hFont,TRUE);

If you're using MFC, there should be a member function of CListBox called SetFont() that does exactly what you're looking for.
 
Are you sure there is a SetFont method. I haven't been able to find nor use it.
 
Apparently, there isn't. Try sending it the message.
 
I got it. I have a ColorListBox.cpp and .h that I included. But thanks for the suggestions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top