CTreeCtrl Check Box
Posted on 2006-10-27
Hi...I have a dialog box with a tree control that has check-boxes in it. What I need to do is, when any of the check-boxes in the tree control is checked, I need to do some processing, and for now let's just say, I need to put up a messagebox. I added a function for the 'NM_CLICK' message to intercept the left button clicks in the tree control, then I do a 'GetCheck' to see if the button is checked.
When I check the box, the 'GetCheck' function returns a 0 but a checkmark appers in the box. When I uncheck the box, the 'GetCheck' function returns a 1, and the checkmark is removed from the box. So this isn't really helping me figure out when the box is checked and not.
Any help would be greatly appericated.
Here is my code for the 'NM_CLICK'
void CDirectoryCheckDlg::OnClickTree1(NMHDR* pNMHDR, LRESULT* pResult)
HTREEITEM ht = m_testTree.HitTest(pt, &uFlags);
if(ht != NULL)
// There is an item under the cursor.
// See what exactly was under the cursor:
// It is the icon (checkbox)
BOOL chkbox = m_testTree.GetCheck(ht);
MessageBox("Button is checked");
// It is the button
*pResult = 0;