怎么选中一行(让底色整行显示),是不是要派生一个类?选中一行的时候,响应函数是什么啊?就是类似CListBox的OnSelChange()的。
按住Ctrl选中多行呢?

解决方案 »

  1.   

    怎么选中一行(让底色整行显示),是不是要派生一个类?
    是的,需要重载DrawItem函数。选中一行的时候,响应函数是什么啊?就是类似CListBox的OnSelChange()的。
    需要响应 LVN_ITEMCHANGED 消息,检测项目的uNewState与uOldState的 LVIS_SELECTED 位是不是不同。按住Ctrl选中多行呢?
    每一个项目被选择时都回发送一个 LVN_ITEMCHANGED 消息,如果你觉得响应太快,可一个设置一个定时器来控制。
      

  2.   

    m_MyList.SetExtendedStyle( LVS_EX_FULLROWSELECT );
    解决选中一行的问题了。
      

  3.   

    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);
      

  4.   

    如何响应CListCtrl里的某一选项被选中??
      

  5.   

    hehe,搞定了。void CDeleteFunction::OnClickList(NMHDR* pNMHDR, LRESULT* pResult) 
    {    for(int i=0;i<m_list.GetItemCount();i++)
    {
    if(m_list.GetItemState(i,LVIS_SELECTED)==LVIS_SELECTED)
    break;
    }     //i为选中的行数 *pResult = 0;
    }