Skip to main content
Email Password   helpLost your password?

Sample Image - CheckComboBox.png

Introduction

This control is actually a modification of the CCheckComboBox class that was written by Magnus Egelberg, Lunalogik. Magnus' control had just about everything I was looking for in a CheckComboBox except one small feature. It did not allow you to check an item in the static text portion of the combo box, you had to drop down the list box in order to make the selections. All the drawing code in this class was written by Magnus. The only additions I made was the code to handle the check box in the static text area, and I removed the dependency on the item data for storing the check state of the items. It is now stored in a CByteArray member variable.

Usage

To use the control, you have to include the CheckComboBox.h header file and add the CheckComboBox.cpp file to your project.

If the control is used on a dialog, it has to have the CBS_DROPDOWNLIST and CBS_OWNERDRAWVARIABLE combo box styles.

Command Notifications

In addition to the regular CBN_* notifications that are generated by the combobox, the CCheckComboBox will also generate a BN_CLICKED notification whenever a user changes the check state of a check box. You can handle the BN_CLICKED notification exactly the same way you would handle it if it was generated by a button control. Use the GetCurSel() member function to get the index of the checkbox that generated the BN_CLICKED notification.

BEGIN_MESSAGE_MAP(CCCheckCombo_demoDlg, CDialog)
    // use the ON_BN_CLICKED macro to catch the BN_CLICKED

    // command that is generated by the CCheckComboBox

    ON_BN_CLICKED(IDC_COMBO1, OnCheckBox)
END_MESSAGE_MAP()
 
...
 
void CCCheckCombo_demoDlg::OnCheckBox()
{
    int sel = m_CheckCombo.GetCurSel();
    CString text;
    m_CheckCombo.GetLBText(sel, text);
    BOOL checked = m_CheckCombo.GetCheck(sel);
    TRACE(_T("Item %d (\"%s\") was %s \n"), sel, 
       text, checked ? _T("checked") : _T("unchecked"));
}

Member Functions

These are the public member functions added to the CCheckComboBox. All CComboBox member functions can also be used.

You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
QuestionDoesn't work on 64-bit Vista Pin
mpietarin
1:33 14 Aug '08  
AnswerRe: Doesn't work on 64-bit Vista Pin
mpietarin
6:30 18 Aug '08  
QuestionUsing this control in ATL Pin
Rajkumar Rachoti
3:10 9 Nov '06  
Questionc# code Pin
mrinal12
14:06 27 Oct '06  
AnswerRe: c# code Pin
PJ Arends
18:27 27 Oct '06  
GeneralDisabling item selection from dropdown list box Pin
Daalu
23:38 20 Sep '06  
GeneralRe: Disabling item selection from dropdown list box Pin
PJ Arends
9:19 21 Sep '06  
GeneralUsage question... Pin
soonaz
6:26 30 Aug '06  
GeneralRe: Usage question... Pin
PJ Arends
7:07 30 Aug '06  
Generalgood... but... Pin
Min-Seok Kim
2:53 26 Jul '05  
GeneralComment Pin
mcbain
2:00 30 Dec '03  
GeneralRe: Comment Pin
PJ Arends
8:04 30 Dec '03  


Last Updated 4 Jul 2004 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2009