Icon Picker Combo Box

To use this icon combo box, follow these simple steps.

  1. Include IconComboBox.cpp and IconComboBox.h in your project.
  2. In the resource editor create a regular combobox with at least the following styles: DropList, OwnerDraw Variable, Has Strings
  3. Create a control member variable for the combobox in VC's classwizard.
  4. Replace CComboBox with CIconComboBox in your  .h file.

Figure1 - Sample picture of the IconComboBox in action

After the IconComboBox is created, you can use the following methods to insert, select and remove icons:

virtual int AddIcon(LPCTSTR lpszIconFileName);
virtual int InsertIcon(int nIndex, LPCTSTR lpszIconFileName);
virtual int SelectIcon(LPCTSTR lpszIconFileName);
virtual int SelectIcon(int nIndex);
virtual int DeleteIcon(LPCTSTR lpszIconFileName);
virtual int DeleteIcon(int nIndex);

The following method can be overrided to paint the icon in a different way. Normally the icon is drawn centered within the combobox.  

virtual void OnOutputIcon(LPDRAWITEMSTRUCT lpDIS, BOOL bSelected);

It is important that the style Has Strings (CBS_HASSTRINGS) is specified, because the filename of the icon is actually stored in the combobox for later use if you select or delete an icon. The width of the combobox is decided by you when you create the control. The height can be set manually with the following statement:

m_cbMyIconComboBox.SetItemHeight(-1, m_cbMyIconComboBox.m_sizeIcon.cy + 6);

where m_sizeIcon.cy are a standard icon height (SM_CYICON).
Download source files - 2 KB


  • help about icon combox

    Posted by miser on 04/16/2004 01:55am

    dear sir, i am a student ,in my homework,i want to add an icon combox, but i cannot do it. i am a new one in the disscussion,i cannot load my icon in the combox ,can you send me a project about icon combox.thank you!

  • Icon Combo

    Posted by Legacy on 02/09/2004 12:00am

    Originally posted by: Srinivas

    But Why am I getting Compilation Errors:

    \IconCombo\IconCombo.vcl(30):G:\usr\kgs\downs\IconCombo\IconComboBox.cpp(31) : error C2039: 'ExtractIcon' : is not a member of '`global namespace''
    \IconCombo\IconCombo.vcl(31):G:\usr\kgs\downs\IconCombo\IconComboBox.cpp(31) : error C2065: 'ExtractIcon' : undeclared identifier
    2 occurrence(s) have been found.

  • If it is a imagelist instead of some icons,how can I do it

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

    Originally posted by: zhengwq

    I wanted to allow certain image selection in one of my projects.The image is from a imagelist.How can I do it?

  • Transparency

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

    Originally posted by: Geny

    I would like to know how to draw icon with transparency in the custom combo box if possible.

  • What about using Borland?

    Posted by Legacy on 05/21/2002 12:00am

    Originally posted by: mike

    i can't get this to compile under Borland. Will it even work under borland?

  • I've yet to get this working.

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

    Originally posted by: blip

    I get a err message when I load the token.

  • how can i do this in vb?

    Posted by Legacy on 02/24/2002 12:00am

    Originally posted by: Mital

    Please Tell me how can i make this thing in vb

  • iconlist in combo box

    Posted by Legacy on 02/15/2002 12:00am

    Originally posted by: Shikha Gupta

    Can I have an icon list in the list box of combo box ? So that icons can be selected off and on !

  • icon picker using vb?

    Posted by Legacy on 01/03/2002 12:00am

    Originally posted by: Jennie Ng


    Is there a way to add icon to a combo box using vb?


  • how can I change the height of combobox

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

    Originally posted by: xyq

    it means that this program can display the icon in
    combobox,but the height of combobox befor clicking the
    combobox doesn't fit the icon.
    hope your answer!

    thanks a million!

  • Loading, Please Wait ...

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

Top White Papers and Webcasts

  • Anthony Christie, the Chief Marketing Officer for Level Communications, is responsible for customer experience, worldwide marketing and product management. In this informative asset, he shares his insights into why a private network connection to cloud-bases applications is the right decision for your enterprise. Download now to find out more.

  • Moving from an on-premises environment to Office 365 does not remove the need to plan for disruptions or reduce the business risk requirements for protecting email services. If anything, some risks increase with a move to the cloud. Read how to ease the transition every business faces if considering or already migrating to cloud email. This white paper discusses: Setting expectations when migrating to Office 365 Understanding the implications of relying solely on Exchange Online security Necessary archiving …

Most Popular Programming Stories

More for Developers

RSS Feeds

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