Checkbox in CListCtrl

Discussion in 'MFC' started by rag84dec, Jan 29, 2008.

  1. rag84dec

    rag84dec New Member

    Joined:
    Jul 17, 2007
    Messages:
    49
    Likes Received:
    0
    Trophy Points:
    0
    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;
    }
    
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice