Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Bitmap in a combo box.

Posted on 1998-08-03
3
468 Views
Last Modified: 2013-11-19
How do I add a little bitmap next to each item in a combo box?  

Thanks.
0
Comment
Question by:syu
3 Comments
 

Expert Comment

by:nari
ID: 1320180
Use owner drawn combo boxes.While creating the combo box using resource editor
set the styles of the combo box to owner draw(fixed or variable) by clicking right mouse
button on after highlighting combo box.Afterwards overwrite DrawItem(..) member
of Combo box then the world is yours.Look in vc++ for more help.
0
 

Author Comment

by:syu
ID: 1320181
If I overwrite DrawItem(), that means I need to derive a class from CComboBox!  Is there any way that I don't need to create a class to put a bitmap on the combo box?  If no, please give details on how to put bitmap in DrawItem().  Set multiple columns, etc.

0
 
LVL 1

Accepted Solution

by:
payn earned 20 total points
ID: 1320182
Why don't you want to derive a class from CComboBox? That's by far the easiest way to do it. The code in MFC's CCheckListBox is a good place to start if you reconsider, and ask specific questions if you get stuck.

However, if you're dead set against it, no, you don't have to derive from CComboBox. An owner-draw control actually sends its messages to the control's parents. The default MFC way to handle this is to reflect them to the controls (it does _not_ call the control's virtual DrawItem, MeasureItem, DeleteItem, as the documentation claims... but the effect is the same, I guess). This makes them effectively "self-draw" rather than "owner-draw." Which, again, is easier to handle, not harder.

Still, you can stop MFC from doing this if you want.

Instead of overriding DrawItem in CComboBox, catch the Windows WM_DRAWITEM message in your CDialog. Make sure not to call the base class version at the end, or it'll reflect the message to the CComboBox, which you apparently don't want.

One more possibility: Fake the combo box by using an edit control and, instead of a listbox, a list common control. Let Win32 draw the icons and manage the columns and all that for you...


0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Separate files macro - Errors on larger data set 18 73
deburging in oracle form 12 104
WinWaitActive parameters 12 31
scoreUp challenge 14 63
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question