Re: Which item was just 'checked' on my tree?
This seems to be good solution
void CTreeCheckDlg::OnNMClickTree1(NMHDR *pNMHDR, LRESULT *pResult)
{
const MSG* pMsg = GetCurrentMessage();
CPoint point(pMsg->pt);
m_Tree.ScreenToClient(&point);
UINT uiFlags = 0;
HTREEITEM ht = m_Tree.HitTest(point, &uiFlags);
if(ht && (uiFlags & TVHT_ONITEMSTATEICON))
{
//since the check state does not change until this function returns
PostMessage(WM_ITEMCHECKED,ht);
}
*pResult = 0;
}
LRESULT CTreeCheckDlg::OnItemChecked(WPARAM,LPARAM)
{
m_Tree.GetCheck(ht);
return 1;
}
AliR.
"AliR (VC++ MVP)" <AliR@online.nospam> wrote in message
news:5QIZh.2126$RX.1715@newssvr11.news.prodigy.net...
You have to get the item yourself.
const MSG* pMsg = GetCurrentMessage();
CPoint point(pMsg->pt);
m_Tree.ScreenToClient(&point);
UINT uiFlags = 0;
HTREEITEM ht = m_Tree.HitTest(point, &uiFlags);
AliR.
"GT" <ContactGT_removeme_@hotmail.com> wrote in message
news:463717f6$0$30231$c3e8da3@news.astraweb.com...
I have a CTreeCtrl populated with a flat list of checkable items. Certain
items require a response when checked, so I am catching the event:
ON_NOTIFY(NM_CLICK, IDC_TREE_RHS, OnNMClickTreeRhs)
This gives my OnNMClickTreeRhs a NMHDR Structure. From the MSDN I can see
that this structure contains:
typedef struct tagNMHDR {
HWND hwndFrom;
UINT idFrom;
UINT code;
} NMHDR;
hwndFrom
Window handle to the control sending a message.
idFrom
Identifier of the control sending a message.
code
Notification code. This member can be a control-specific notification
code or it can be one of the common notification codes.
I can't find useful help beyond this in the MSDN. Is there a way to find
out the HTREEITEM clicked or the LPARAM for the clicked tree item from
this structure? Is the hwndFrom perhaps the HTREEITEM or can I get that
from the 'code'. I can't use the selected Item as clicking the checkbox
on another item, doesn't change the selection!