Color List Box With Extra Bits

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 http://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);

Downloads

Download demo project - 20 Kb
Download source - 5 Kb


Comments

  • Multiple Selection?

    Posted by Saturion on 04/05/2006 05:36am

    Is it possible to select mutltiple objects? Is this disabled or are they simply not drawn?

    Reply
  • Download link broken?

    Posted by spudlips on 12/16/2005 03:21pm

    Demo project and source links fail.

    • No Problem !

      Posted by Promotional Engine on 08/22/2006 10:20pm

      I can download both with no problem.

      Reply
    Reply
  • Sorting?

    Posted by alforno on 09/28/2004 04:48pm

    It seems like the sorting is not working when I use this class. Anyone know how to turn it back on or why it isn't working?

    Reply
  • settabstops

    Posted by Legacy on 10/20/2003 12:00am

    Originally posted by: Johan

    How can I use with settabstops() ? it doesnt seem to work for me.

    /Johan

    Reply
  • Disabled Item?

    Posted by Legacy on 06/24/2003 12:00am

    Originally posted by: David

    Can anyone explain what the difference is between active and inactive items?

    Reply
  • Disabled Control?

    Posted by Legacy on 12/04/2002 12:00am

    Originally posted by: Tommy Evans

    If I disable the control, the background still shows normal (as if it was enabled). How do you change it so it appears disabled?

    Thanks - this is an awesome control!

    Reply
  • how to change to backgroud image?

    Posted by Legacy on 07/16/2002 12:00am

    Originally posted by: linda

    can u change ur back image ,not color !Thanks a lot!

    Reply
  • How to change to italics

    Posted by Legacy on 11/01/2001 12:00am

    Originally posted by: Benilu

    Do you know how to switch the font so that it draws on italics?

    To email, eliminate underscore

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • As all sorts of data becomes available for storage, analysis and retrieval - so called 'Big Data' - there are potentially huge benefits, but equally huge challenges...
  • The agile organization needs knowledge to act on, quickly and effectively. Though many organizations are clamouring for "Big Data", not nearly as many know what to do with it...
  • Cloud-based integration solutions can be confusing. Adding to the confusion are the multiple ways IT departments can deliver such integration...

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date