Click here to Skip to main content
15,891,431 members
Articles / Desktop Programming / MFC
Article

ComboBox bold - Combo box with bold text items and optional icon.

Rate me:
Please Sign up or sign in to vote.
4.21/5 (14 votes)
5 Aug 2003 171.8K   4.4K   49   30
Combo Box that allows you to set some of the items to be bold

Introduction

This is simple extension to the basic MFC combo box.

Usage

  1. Create a combo box in your dialog, make it "owner draw fixed" and "has strings".
  2. Then just add a member to the dialog for that combo, of type CComboBoxBold.
  3. Then use the functions of the CComboBoxBold as follows:
    CComboBoxBold::SetIcon(int itemId,int iconId);
    CComboBoxBols::SetItemBold(int itemId, BOOL bold);

Example:

BOOL CBoldComboDemoDlg::OnInitDialog()
{
    CDialog::OnInitDialog();
    // Set the icon for this dialog. The framework does this automatically
    // when the application's main window is not a dialog
    SetIcon(m_hIcon, TRUE); // Set big icon
    SetIcon(m_hIcon, FALSE); // Set small icon
    // TODO: Add extra initialization here
    m_combo.SetItemBold(2,TRUE);
    m_combo.SetItemBold(4,TRUE);
    m_combo.SetIcon(0,IDI_ICON2);
    m_combo.SetIcon(1,IDI_ICON3);
    m_combo.SetIcon(2,IDI_ICON4);
    m_combo.SetIcon(3,IDI_ICON6);
    m_combo.SetIcon(5,IDI_ICON2);
    m_combo.SetIcon(6,IDI_ICON4);
    return TRUE; // return TRUE unless you set the focus to a control
}

History

Aug 6, 2003 - Updated source and demo project.

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
Software Developer (Senior) RDV Systems
Israel Israel
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralIt doesn't provide CBS_OWNERDRAWFIXED in CE Pin
Small Man21-Aug-03 15:27
Small Man21-Aug-03 15:27 
GeneralRe: It doesn't provide CBS_OWNERDRAWFIXED in CE Pin
Alex Hazanov23-Aug-03 20:21
Alex Hazanov23-Aug-03 20:21 
GeneralRe: It doesn't provide CBS_OWNERDRAWFIXED in CE Pin
natenez29-Sep-03 12:43
natenez29-Sep-03 12:43 
GeneralRe: It doesn't provide CBS_OWNERDRAWFIXED in CE [modified] Pin
mahendra.pardeshi18-Apr-07 22:56
mahendra.pardeshi18-Apr-07 22:56 
GeneralMultiple Icons Pin
Alex Hazanov6-Aug-03 20:01
Alex Hazanov6-Aug-03 20:01 
GeneralRe: Multiple Icons Pin
Ravi Bhavnani7-Aug-03 4:18
professionalRavi Bhavnani7-Aug-03 4:18 
GeneralRe: Multiple Icons Pin
Alex Hazanov9-Aug-03 20:27
Alex Hazanov9-Aug-03 20:27 
GeneralRe: Multiple Icons Pin
Octopod20-Nov-09 5:40
Octopod20-Nov-09 5:40 
From one single bitmap resource rather than multiple bitmaps per icons.
GeneralGood, but... Pin
alex.barylski3-Aug-03 14:18
alex.barylski3-Aug-03 14:18 
GeneralDifferent icon per item Pin
Andrew Allen16-Jul-03 22:33
Andrew Allen16-Jul-03 22:33 
GeneralRe: Different icon per item Pin
Alex Hazanov16-Jul-03 22:42
Alex Hazanov16-Jul-03 22:42 

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.