In CGXCheckListComboBox it would be useful if the checkbox is checked/unchecked when I click on the item. Now I have to click necessarily to the checkbox, not to the entire item. How to override this behavior?
You should derive a class from CGXCheckListComboLBox (which itself is a derivative from the MFC CCheckListBox). In the subclass you can process the WM_LBUTTONDOWN message as shown below. Furthermore, you have to subclass CGXCheckListComboBox class and override the CreateListBox member. There you should instantiate your CGXCheckListComboLBox derivative.
(code copied from the CCheckListBox and modified slightly)
void CYourCheckListComboLBox::OnLButtonDown(UINT nFlags, CPoint point)
{
m_bLButtonDown = TRUE;
m_nOldSel = GetCurSel();
SetFocus();
// determine where the click is
BOOL bInCheck;
int nIndex = CheckFromPoint(point, bInCheck);
// if the item is disabled, then eat the click
if (!IsEnabled(nIndex))
return;
if (m_nStyle != BS_CHECKBOX && m_nStyle != BS_3STATE)
{
// toggle check mark automatically if check mark was hit
if (TRUE) //This was if(bInCheck) in the base class
{
CWnd* pParent = GetParent();
ASSERT_VALID(pParent);
int nModulo = (m_nStyle == BS_AUTO3STATE) ? 3 : 2;
int nCheck = GetCheck(nIndex);
nCheck = (nCheck == nModulo) ? nCheck - 1 : nCheck;
SetCheck(nIndex, (nCheck + 1) % nModulo);
InvalidateCheck(nIndex);
CListBox::OnLButtonDown(nFlags, point);
// Inform of check
pParent->SendMessage(WM_COMMAND,
MAKEWPARAM(GetDlgCtrlID(), CLBN_CHKCHANGE),
(LPARAM)m_hWnd);
return;
}
}
// do default listbox selection logic
CListBox::OnLButtonDown(nFlags, point);
}