LVS_EX_FULLROWSELECT //The macro ListView_GetExtendedListViewStyle takes a reference to the // CListCtrl and returns the current extended style (a DWORD) DWORD dwStyle = ListView_GetExtendedListViewStyle(GetListCtrl()); //Add the full row select and grid line style to the existing extended styles dwStyle |= LVS_EX_FULLROWSELECT; //The macro ListView_SetExtendedListViewStyle takes a reference to the // CListCtrl and the extended style you would like to implement ListView_SetExtendedListViewStyle( GetListCtrl(),dwStyle);
是的,需要重载DrawItem函数。选中一行的时候,响应函数是什么啊?就是类似CListBox的OnSelChange()的。
需要响应 LVN_ITEMCHANGED 消息,检测项目的uNewState与uOldState的 LVIS_SELECTED 位是不是不同。按住Ctrl选中多行呢?
每一个项目被选择时都回发送一个 LVN_ITEMCHANGED 消息,如果你觉得响应太快,可一个设置一个定时器来控制。
解决选中一行的问题了。
//The macro ListView_GetExtendedListViewStyle takes a reference to the
// CListCtrl and returns the current extended style (a DWORD) DWORD dwStyle = ListView_GetExtendedListViewStyle(GetListCtrl()); //Add the full row select and grid line style to the existing extended styles
dwStyle |= LVS_EX_FULLROWSELECT; //The macro ListView_SetExtendedListViewStyle takes a reference to the
// CListCtrl and the extended style you would like to implement ListView_SetExtendedListViewStyle( GetListCtrl(),dwStyle);
{ for(int i=0;i<m_list.GetItemCount();i++)
{
if(m_list.GetItemState(i,LVIS_SELECTED)==LVIS_SELECTED)
break;
} //i为选中的行数 *pResult = 0;
}