Click here to Skip to main content
11,411,840 members (49,494 online)
Click here to Skip to main content

Skin the ComboBox in 3 simple function calls

, 24 Mar 2004
Rate this:
Please Sign up or sign in to vote.
Set the skin for combobox drop down list of combo box.

Sample Image - Skin_Combo_Box.jpg


This is a simple sub classed control from CComboBox that allows you to apply skin to the combobox and its droplist. The skins used can be a pixel wide (for the background and corners of the droplist) to keep the control light.

The CComboBox overrides

The following functions are overridden (just like in most of the sub classed controls). It's all easy to understand.

virtual BOOL Create(LPCTSTR lpszClassName, 
    LPCTSTR lpszWindowName, DWORD dwStyle, 
    const RECT& rect, CWnd* pParentWnd, UINT nID, 
    CCreateContext* pContext = NULL);
virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
afx_msg void OnPaint();
afx_msg void OnDestroy();
afx_msg LRESULT OnCtlColorListBox(WPARAM wParam, LPARAM lParam);

The following function is taken from the multicombobox project on Code Project (sorry I forgot the author and link).

afx_msg LRESULT OnCtlColorListBox(WPARAM wParam, LPARAM lParam);

How to use

It's very simple to use. Add a combobox on the dialog box, make a member variable of CComboBox type, change the type of object to CBitComboBox in the Dialog header file, and add the bitmaps in the resource to skin the combobox.

Change the header file to look as following:

Include BitComboBox header:

#include "BitComboBox.h"

Change the control's class to CBitComboBox from CComboBox.

CBitComboBox m_cmbBitmap;

Call the following functions in CBitComboBox class to set resource IDs of the skin bitmaps on OnInitDialog (or anywhere in your project before combo box is created).

m_cmbBitmap.SetHighlightColor(RGB(115,138,174), RGB(255,255,255));
m_cmbBitmap.SetNormalPositionColor(RGB(115,138,154), RGB(255,255,255));

What is missing

There are following things missing, if someone can complete them please let me know:

  1. If there is no skin set a default combobox should appear (Can be done by simply calling the CComboBox functions from overrides).
  2. I have not implemented the skins for edit control of combobox (Can be done in OnCtrlColor of CBitComboBox).


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

Ashok Jaiswal
Web Developer
Hong Kong Hong Kong
innovating, managing and developing next generation media products and services

Comments and Discussions

QuestionDynamically create button PinmemberMember 114400852-Apr-15 20:32 
GeneralMy vote of 4 Pinmembersun mi Kang11-Sep-13 22:24 
GeneralMy vote of 5 PinmemberJJMatthews20-Apr-12 4:12 
QuestionHow to use the skins for edit control of comboboxex? [modified] Pinmemberwanglinhai88826-Nov-09 19:53 
Generalproblem with scrollbar PinmemberMircea Grelus7-Oct-05 1:41 
Generalsubclassing listbox PinmemberEngin Lee7-Apr-05 4:56 
GeneralRe: subclassing listbox Pinmemberartsmouse25-May-05 4:09 
GeneralRe: subclassing listbox PinsussEngin Lee25-May-05 5:21 
GeneralResize Windows Pinmembercochondinde29-Dec-04 14:28 
GeneralScrollbar PinmemberHolli H.28-Oct-04 5:54 
GeneralDrawText PinmemberOrxorand30-Sep-04 3:20 
GeneralAnother another bug, crash and SetCurSel(2) does not work, here is the remedy PinmemberDr. Sai21-Sep-04 0:39 
GeneralRe: Another another bug, crash and SetCurSel(2) does not work, here is the remedy PinmemberAshok Jaiswal21-Sep-04 16:14 
GeneralAnother Bug PinmemberDr. Sai16-Sep-04 1:48 
GeneralBitmap down arrow button Pinmembervivadotnet20-Jun-04 17:49 
GeneralRe: Bitmap down arrow button PinmemberOrxorand4-Oct-04 3:30 
GeneralIt crashes when focus comes to skinned combo using down arrow key PinmemberAtif Mushtaq25-Mar-04 1:23 
GeneralRe: It crashes when focus comes to skinned combo using down arrow key PinmemberAshok Jaiswal25-Mar-04 15:22 
GeneralRe: It crashes when focus comes to skinned combo using down arrow key Pinmemberwhatisron3-Apr-04 12:32 

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

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

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150414.5 | Last Updated 25 Mar 2004
Article Copyright 2004 by Ashok Jaiswal
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid