Color Listbox

I needed a listbox showing colors and text strings for a legend. When I didn't find any, I decided to create my own, based on Color Picker Combo Box (3) by James R. Twine.

It has the same functionality, except it is based on a CListbox instead of a CCombobox.

To use it: Define a Listbox on a dialog. Set the properties to owner-draw, with strings, and create a member variable of control type for it. Then replace the CListbox type with CColorListbox.

// in dialog.h
//{{AFX_DATA(CMyDlg)
enum { IDD = IDD_MY_DIALOG };
CColorListBox	m_ctrList1;
//}}AFX_DATA

Downloads

Download source - 4 Kb



Comments

  • Owner Draw, ok. But... which one?

    Posted by Nelek on 07/24/2006 07:19am

    Hi, IB4m using Visual C++ 6.0 and IB4m going to use your CColorListBox. I have seen that there are different options to select in "Owner-Draw": None, Fixed and Variable. Which one should we use? Fixed or Variable?

    Reply
  • "ami.h"

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

    Originally posted by: Rong Yao

    Nice job! But where is "ami.h"?

    Reply
  • Subclass a listbox

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

    Originally posted by: SamZheng

    Could someone explain how to subclass a listbox, so I can fill different background colors for each item in the list?
    Thanks.

    Reply
  • Why list box can not selected?

    Posted by Legacy on 04/30/2001 12:00am

    Originally posted by: Guo zanhua

    When i use CreateWindow() create a listbox,
    and i am sure the create style is single selection,
    but i can not select any of item in the list box
    control.

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

Top White Papers and Webcasts

  • On-demand Event Event Date: September 10, 2014 Modern mobile applications connect systems-of-engagement (mobile apps) with systems-of-record (traditional IT) to deliver new and innovative business value. But the lifecycle for development of mobile apps is also new and different. Emerging trends in mobile development call for faster delivery of incremental features, coupled with feedback from the users of the app "in the wild." This loop of continuous delivery and continuous feedback is how the best mobile …

  • As mobile devices have pushed their way into the enterprise, they have brought cloud apps along with them. This app explosion means account passwords are multiplying, which exposes corporate data and leads to help desk calls from frustrated users. This paper will discover how IT can improve user productivity, gain visibility and control over SaaS and mobile apps, and stop password sprawl. Download this white paper to learn: How you can leverage your existing AD to manage app access. Key capabilities to …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds