在没有添加LVS_EX_FULLROWSELECT风格前,只能点击列表项的第一列的区域现在我的需求是不能点击第一例的区域,而可以点击其他列的区域地项不知我表达清楚没,希望看懂了的朋友给个建议!

解决方案 »

  1.   

    自己响应WM_LBUTTONDOWN消息,用HitTest判断一下,如果是点在第1列,就直接返回,不调用基类的响应函数。
      

  2.   

    楼主说的列我没太懂 是不是指行啊?如果不是楼主改改下面的代码应该就可以了。下面是一段代码,第一行不能点中:
    BOOL C**Dlg::PreTranslateMessage(MSG* pMsg) 
    {
    if( WM_LBUTTONDOWN == pMsg->message )            //截获对话框的右键消息
    {
    CListCtrl* listWnd = ( CListCtrl* )GetDlgItem( IDC_LIST1 ); //取得CListCtrl控件的窗口句柄

    CPoint pt; ::GetCursorPos( &pt );                           //取得鼠标的屏幕坐标

    CRect OxRT;                              
    listWnd->GetItemRect( 0, OxRT,LVIR_BOUNDS ); //取得条目0(第一行的区域)
    listWnd->ClientToScreen(&OxRT);              //转换为屏幕坐标

    if( OxRT.PtInRect( pt ) )                    //判断鼠标是否在当前条目所占的矩形区域当中
    {
    return TRUE;     //如果确定是第一行,直接返回
    }
    } return CDialog::PreTranslateMessage(pMsg);
    }其中需要特别注意的是GetItemRect( 0, OxRT,LVIR_BOUNDS ); 这个函数的第三个参数:
    意思是(MSDN):
    //Portion of the list view item for which to retrieve the bounding rectangle. It can be one of these values://LVIR_BOUNDS   Returns the bounding rectangle of the entire item, including the icon and label.//LVIR_ICON   Returns the bounding rectangle of the icon or small icon.//LVIR_LABEL   Returns the bounding rectangle of the item text.