Solved

Bitmap in a combo box.

Posted on 1998-08-03
3
472 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
[X]
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
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

730 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