NM_CLICK (list view) Sent by a list-view control when the user clicks an item with the left mouse button. This notification message is sent in the form of a WM_NOTIFY message. NM_CLICK lpnmitem = (LPNMITEMACTIVATE) lParam;Parameters lpnmitem Version 4.71. Address of an NMITEMACTIVATE structure that contains additional information about this notification message. The iItem, iSubItem, and ptAction members of this structure contain information about the item. Return Values The return value for this notification is not used. Res This notification is identical to the standard NM_CLICK notification except that in version 4.71 and later, the list view supplies an NMITEMACTIVATE structure instead of an NMHDR structure for the lParam. The iItem member of lpnmitem will only be valid if the icon or first-column label has been clicked. To determine which item is selected when a click takes place elsewhere in a row, send an LVM_SUBITEMHITTEST message.
LVS_SINGLESEL Allows only one item at a time to be selected. By default, multiple items can be selected.
CListCtrl m_List; m_List.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_SINGLESEL ); //只能选择一个而不是多个 POSITION pos =m_ListView.GetFirstSelectedItemPosition(); int intIndex=m_ListView.GetNextSelectedItem(pos); //intIndex的 值 就 是 当前选中的是第几个
for(i=0,i<m_List.GetItemCount();i++
{
m_List.SetCheck(i,FALSE);
}POSITION pos =m_ListView.GetFirstSelectedItemPosition();
int intIndex=m_ListView.GetNextSelectedItem(pos);
if(intIndex<=0)intIndex=0;
m_List.SetCheck(intIndex,FALSE);
再问在NM_CLICK消息中如何知道当前选中的是第几个,还有,如何让LISTCTRL只能选择一个而不是多个?
谢谢!
Sent by a list-view control when the user clicks an item with the left mouse button. This notification message is sent in the form of a WM_NOTIFY message. NM_CLICK
lpnmitem = (LPNMITEMACTIVATE) lParam;Parameters
lpnmitem
Version 4.71. Address of an NMITEMACTIVATE structure that contains additional information about this notification message. The iItem, iSubItem, and ptAction members of this structure contain information about the item.
Return Values
The return value for this notification is not used. Res
This notification is identical to the standard NM_CLICK notification except that in version 4.71 and later, the list view supplies an NMITEMACTIVATE structure instead of an NMHDR structure for the lParam. The iItem member of lpnmitem will only be valid if the icon or first-column label has been clicked. To determine which item is selected when a click takes place elsewhere in a row, send an LVM_SUBITEMHITTEST message.
m_List.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_SINGLESEL );
//只能选择一个而不是多个
POSITION pos =m_ListView.GetFirstSelectedItemPosition();
int intIndex=m_ListView.GetNextSelectedItem(pos);
//intIndex的 值 就 是 当前选中的是第几个