To make check boxes act like radio buttons (mutually exclusive)
Posted
by Praveen S. Kumar
on February 1st, 1999
void CListDlg::OnItemchangedMylist(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
/* 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)
return;
// 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)
for(nCount=0;nCount<m_listctl.GetItemCount();nCount++)
if(nCount != pNMListView->iItem)
m_listctl.SetCheck(nCount, FALSE);
}
Date Last Update: February 1, 1999

Comments
There are no comments yet. Be the first to comment!