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.
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;
}
判断它的状态不就知道了么。
setcheck(int nItem,BOOL bPaint);
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.