To make check boxes act like radio buttons (mutually exclusive)

If you have a list control in your dialog with the LVS_EX_CHECKBOXES style, you can make the check boxes to act like radiobuttons by adding two lines of code.. First map the LVN_ITEMCHANGED event of the list control from the class wizard and add the code shown

void CListDlg::OnItemchangedMylist(NMHDR* pNMHDR, LRESULT* pResult)

 /* If the event is not fired because of any change in individual items then the oldstate and 
 newstate members of pNMListView are not used.  So check for that.*/

 if (!pNMListView->uOldState && !pNMListView->uNewState)

 // m_listctl is the member variable of the dialog which is of type CListCtl.
 BOOL bChecked = ListView_GetCheckState(m_listctl.m_hWnd, pNMListView->iItem);

 // if it's checked uncheck everything else.
 int nCount;

 if (bChecked)
   if(nCount != pNMListView->iItem)
    m_listctl.SetCheck(nCount, FALSE);

Date Last Update: February 1, 1999