Click here to Skip to main content
15,885,309 members
Articles / Desktop Programming / MFC

A Combobox with bitmaps

Rate me:
Please Sign up or sign in to vote.
4.75/5 (6 votes)
24 Nov 1999 334K   6.6K   61   25
A combo box that can be used to display bitmaps

Sample Image

This control was made after the useful Icon Picker Combo Box by Joel Wahlberg.

Usage

  1. Include CBitmapPickerCombo.cpp and CBitmapPickerCombo.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 CBitmapPickerCombo in your dialog's .h file
  5. In OnInitDialog, use the AddBitmap or InsertBitmap member functions to add CBitmaps (and optional strings) to the combobox

The height of the combobox is automatically set to the highest bitmap.

Relevant Member Function Prototypes

C++
int CBitmapPickerCombo::AddBitmap(const CBitmap *bitmap, const char *string = NULL);
int CBitmapPickerCombo::InsertBitmap
    (int nIndex, const CBitmap *bitmap, const char *string = NULL);

License

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.


Written By
Web Developer
Netherlands Netherlands
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Question64 bit Pin
freddykatz26-Jan-23 5:02
freddykatz26-Jan-23 5:02 
QuestionStill works after 20 years! Pin
Member 1234417514-Feb-19 6:53
Member 1234417514-Feb-19 6:53 
GeneralStrange behavior on scrolling Pin
indra2025-Jun-06 21:04
indra2025-Jun-06 21:04 
GeneralRe: Strange behavior on scrolling Pin
Michael Gunlock28-Oct-07 18:24
Michael Gunlock28-Oct-07 18:24 
It is a bug with the animation of the listbox control and is dependent on the system visual effects settings.

If the "smooth-scroll list boxes" visual effects setting is checked (in XP this is located in System Properties | Advanced | Visual Effects | Custom...) AND the listbox is owner-draw, then the animation of the control gets screwed up. A hack I have used is to call SystemParametersInfo using the SPI_SETLISTBOXSMOOTHSCROLLING parameter to enable and disable this when the control gains and loses focus, respectively. You should reset the users visual effect settings back to the original state when the control loses focus.

GeneralDrop down window zero height Pin
Obliterator10-Jun-05 4:34
Obliterator10-Jun-05 4:34 
GeneralRe: Drop down window zero height Pin
Anonymous18-Aug-05 6:49
Anonymous18-Aug-05 6:49 
Questionhow to link data in combo box to dialog box Pin
jinshi22-Jan-05 19:58
jinshi22-Jan-05 19:58 
GeneralNIce Pin
sreejith ss nair11-Dec-04 22:15
sreejith ss nair11-Dec-04 22:15 
GeneralIntergration with MFCGrid Pin
MHillary23-Jul-04 6:14
MHillary23-Jul-04 6:14 
QuestionHow to delete bitmap? Pin
blueh28-Sep-03 23:16
blueh28-Sep-03 23:16 
AnswerRe: How to delete bitmap? Pin
Mark Monnin24-Jul-07 8:27
Mark Monnin24-Jul-07 8:27 
Generalgood Pin
lovexinqing30-Mar-03 10:42
lovexinqing30-Mar-03 10:42 
GeneralRe: good Pin
KongShan13-May-03 14:57
KongShan13-May-03 14:57 
GeneralRe: good Pin
Anonymous17-May-03 13:50
Anonymous17-May-03 13:50 
GeneralRe: good Pin
teli198213-Jun-05 17:55
teli198213-Jun-05 17:55 
GeneralUnable to place other bitmaps Pin
7-May-01 22:30
suss7-May-01 22:30 
GeneralRe: Unable to place other bitmaps Pin
Marron23-Jan-04 10:32
Marron23-Jan-04 10:32 
GeneralRe: Unable to place other bitmaps Pin
vadimpl11-May-06 9:16
vadimpl11-May-06 9:16 
QuestionWhy not use CComboBoxEx? Pin
David Saulnier26-May-00 10:11
David Saulnier26-May-00 10:11 
AnswerRe: Why not use CComboBoxEx? Pin
Member 195890516-Jun-00 5:18
Member 195890516-Jun-00 5:18 
AnswerRe: Why not use CComboBoxEx? Pin
28-Feb-02 13:02
suss28-Feb-02 13:02 
GeneralCombobox on a CDialogBar Pin
Member 686951-Mar-00 7:18
Member 686951-Mar-00 7:18 
GeneralRe: Combobox on a CDialogBar Pin
11-Jun-01 22:29
suss11-Jun-01 22:29 
GeneralRe: Combobox on a CDialogBar Pin
25-Jul-01 3:11
suss25-Jul-01 3:11 
GeneralRe: Combobox on a CDialogBar ;) Pin
Remi Morin26-Jul-01 3:08
Remi Morin26-Jul-01 3:08 

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.