Click here to Skip to main content
13,449,562 members (38,755 online)
Click here to Skip to main content
Add your own
alternative version


55 bookmarked
Posted 10 Sep 2002

Owner Draw List Box with Icons and Text

, 14 Sep 2002
Rate this:
Please Sign up or sign in to vote.
Easy to implementation Owner Draw List Box

Sample Image - _ListBoxCH.jpg


The article presents an implementation of an owner drawn ListBox with the icon and text.

Before programming, you can use resource editor to create a list box template which properties must be set. Select Variable for owner draw and check Want key to input, then uncheck Sort and Has strings check box. Import your favorite icon to your project if you want to display in list box (the icon only support 32x32 dimension size image), then add ListBoxCH.h and ListBoxCH.cpp, two files to your project and add following line to the top where you want to use CListBoxCH:

#include "ListBoxCH.h"

Then add following statements to implement owner draw list box:

// attach dialog template to the CWnd object
// add item 

Initial owner draw list box:

// set default selected index.

The CListBoxCH has some operations. Member functions can set or change owner draw list box surface:

class CListBoxCH: public CListBox
// Operations
    // set active selected color
    void SetSelColor(COLORREF clr);
    // set inactive background (unselected) color 
    void SetBgColor(COLORREF clr);
    // change or set current select index
    void SetCurSel(int curSel);
    // set text color
    void SetTextColor(COLORREF clr);
    //  display separator edge ?  
    void EnableEdge(BOOL bEnable); 
    // get current selected index
    int  GetCurSel(); 


This owner draw list box is very simple. You can add your code to this class or add other message handler to this class.

Happy programming!


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

chia hung liu
Web Developer
Taiwan Taiwan
I'm a software engineer for a R&D department developing specialised user interface software for the automation industry.

I enjoy coding and researching algorithm.

You may also be interested in...

Comments and Discussions

Questionobvious vestigial while mouse wheel scrolling Pin
jonney309920-Jan-15 20:47
memberjonney309920-Jan-15 20:47 
Generalgood articl Pin
jksnt_199919-Dec-12 18:11
memberjksnt_199919-Dec-12 18:11 
QuestionMemory Leak? Pin
basti271128-Nov-07 4:49
memberbasti271128-Nov-07 4:49 
GeneralEditable Listbox Pin
basti27117-Jun-07 22:08
memberbasti27117-Jun-07 22:08 
QuestionHow can i load icons fron the specified filepath directly. Pin
phani130212-Apr-07 20:12
memberphani130212-Apr-07 20:12 
QuestionMore Doubts from this article.. Pin
klvin16-Jan-07 20:13
memberklvin16-Jan-07 20:13 
GeneralMore Doubts from this article.. Pin
klvin16-Jan-07 20:00
memberklvin16-Jan-07 20:00 
QuestionHow can I add icons to listbox without using MFC Pin
p_peto2-Jun-05 23:50
memberp_peto2-Jun-05 23:50 
AnswerRe: How can I add icons to listbox without using MFC Pin
n_vas10-Nov-06 8:52
membern_vas10-Nov-06 8:52 
General16*16 icons Pin
d00_ape23-Sep-04 3:13
memberd00_ape23-Sep-04 3:13 
GeneralA few minor problems... Pin
Robin Hilliard12-Sep-02 0:52
memberRobin Hilliard12-Sep-02 0:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04-2016 | 2.8.180318.3 | Last Updated 15 Sep 2002
Article Copyright 2002 by chia hung liu
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid