Environment:
Developed using VC6, tested on Win2k Pro and XP Pro.
This MFC CListBox class extension is result of searching for a listbox that does exactly what I have implemented here, except for the vertical alignment. After browsing through CodeGuru site, I found some code but none that fully matched my project needs. Still, all the credit to Patrice Godard and Paul M. Meidinger for designing CColorListBox class, found at
https://www.codeguru.com/listbox/colorlb.shtml, that I got the idea from.
CListBoxEBX Features
- Background color.
- Foreground color.
- Text horizontal alignment.
- Text vertical alignment.
- Indicating inactive items.
- Hooking of a DWORD value per item as in original SetItemData().
- Allows for setting of the items height
Future desired features
- Font manipulation.
- Use of images
- Horizontal scrolling.
// Instantiate the wrapper for the list box window
CListBoxEBX m_xList;// This can be inserted in the ::OnInitDialog()
m_xList.SetItemHeight(40);
m_xList.AddItem(“First string”);
m_xList.AddItem(“Last string”);
m_xList.InsertItem(“Middle string #1”, 1, RGB(50, 100, 150),
RGB(255, 255,255));
m_xList.InsertItem(“Middle string #2”, 1, RGB(100, 150, 200),
RGB(255, 255,255));
m_xList.InsertItem(“Middle string #3”, 1, 12432321,
RGB(255, 255,255));m_xList.SetActive(FALSE, 2);
m_xList.SetCurSel(0);