Solved

Bitmap in a combo box.

Posted on 1998-08-03
3
481 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

Industry Leaders: 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: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…

707 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