Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Bitmap in a combo box.

Posted on 1998-08-03
3
Medium Priority
?
504 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 40 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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…
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.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

636 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