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.
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;
}
Comment