如题:当我点击每行前面的checkbox框,进行选中或者取消时,
程序用什么事件来捕获而让我知道点击了checkbox框?

解决方案 »

  1.   

    响应NM_CLICK消息:
    void CXXXDlg::OnClickTree1(NMHDR* pNMHDR, LRESULT* pResult) 
    {
    // TODO: Add your control notification handler code here
     CPoint pt; 
     UINT flag; 
     HTREEITEM hCurrentItem,TItem;       
     GetCursorPos(&pt); 
     m_tree.ScreenToClient(&pt); 
     hCurrentItem = m_tree.HitTest(pt, &flag); 
     m_tree.Select(hCurrentItem,TVGN_CARET); 
     if(NULL != hCurrentItem)
     {
     CString strText(_T(""));
     strText=m_tree.GetItemText(hCurrentItem);  
     
     if (flag & TVHT_ONITEMSTATEICON )       //µã»÷ÔÚCheckBoxÉÏ         
     {         
     if (m_tree.GetCheck(hCurrentItem)) 
     { 
     AfxMessageBox(strText + _T("Check"));
     } 
     else 
     { 
     AfxMessageBox(strText + _T("No Check"));
     } 
     
     }
     else if( flag & TVHT_ONITEMBUTTON )       //µã»÷ÔÚ+ºÅÉÏ         
     {         
     AfxMessageBox("In +");         

     } *pResult = 0;
    }
      

  2.   

    双击list,不是有个函数的么,你在里面处理好了。
    判断它的状态不就知道了么。
    setcheck(int nItem,BOOL bPaint);
      

  3.   

    对了, 还有一个是Getcheck(int nItem)
      

  4.   

    ListView_GetCheckState 
    List-View Controls MacrosRequirements
    OS Versions: Windows CE 2.0 and later.
    Header: Commctrl.h.
    This macro determines if an item in a list-view control is selected. This should be used only for list-view controls that have the LVS_EX_CHECKBOXES style. BOOL ListView_GetCheckState(
      HWND hwndLV, 
      UINT iIndex 
    );
    Parameters
    hwndLV 
    Handle to a list-view control. 
    iIndex 
    Index of the item for which to retrieve the check state.