Go4Expert

Go4Expert (http://www.go4expert.com/)
-   MFC (http://www.go4expert.com/forums/mfc/)
-   -   Checkbox in CListCtrl (http://www.go4expert.com/forums/checkbox-in-clistctrl-t8537/)

rag84dec 29Jan2008 16:33

Checkbox in CListCtrl
 
Hi,
I have many check boxes in a list control.My problem is to uncheck the check box if there is a check box already checked.How can i do??..I tried doing the below but it checks the first check box and unchecks the others.

Code:

void SomeClass::OnCheckboxChanged
( NMHDR*                  pNMHeader,
  LRESULT*                pResult )
{
func();
}
bool SomeClass::func
(void)
{
  CListCtrl* a_pStatus = (CListCtrl*) GetDlgItem(IDC_DLG_FWUPDATE);
        OC_ULong_t a_NoChecked=0;
  for(OC_ULong_t  a_Index=0;a_Index<a_pStatus->GetItemCount() ;a_Index++)
  {
    // See if the check was selected
    if(a_pStatus->GetItemState(a_Index,LVIS_STATEIMAGEMASK) == INDEXTOSTATEIMAGEMASK(2))
    {
                        a_NoChecked++;
                        if(a_NoChecked>1)
                                a_pStatus->SetCheck(a_Index,false);
                       
    }
  }
        //if(a_NoChecked==1)
    //  return true;
                        //else
                        //return false;
  return true;
}



All times are GMT +5.5. The time now is 10:37.