Deselecting Tree Node Item in MFC
-
How to deselect the tree item when clicking outside the tree node (i need to remove focusbox). I used the below code but i failed. void CEditableView::OnLButtonDown(UINT nFlags, CPoint point) { TVHITTESTINFO tvInfo; CPoint pt; HTREEITEM m_pOldSel; GetCursorPos(&pt); m_treeCtrl.ScreenToClient(&pt); tvInfo.pt = pt; UINT uFlags = 1; UINT flags; HTREEITEM htItem = m_treeCtrl.HitTest(pt); if ((htItem != NULL)) { m_pOldSel = m_treeCtrl.GetSelectedItem(); m_treeCtrl.Select(htItem, TVGN_DROPHILITE); m_treeCtrl.GetCheck(htItem); } else { m_treeCtrl.Select(htItem, TVGN_DROPHILITE); } CView::OnLButtonDown(nFlags, point); }
-
How to deselect the tree item when clicking outside the tree node (i need to remove focusbox). I used the below code but i failed. void CEditableView::OnLButtonDown(UINT nFlags, CPoint point) { TVHITTESTINFO tvInfo; CPoint pt; HTREEITEM m_pOldSel; GetCursorPos(&pt); m_treeCtrl.ScreenToClient(&pt); tvInfo.pt = pt; UINT uFlags = 1; UINT flags; HTREEITEM htItem = m_treeCtrl.HitTest(pt); if ((htItem != NULL)) { m_pOldSel = m_treeCtrl.GetSelectedItem(); m_treeCtrl.Select(htItem, TVGN_DROPHILITE); m_treeCtrl.GetCheck(htItem); } else { m_treeCtrl.Select(htItem, TVGN_DROPHILITE); } CView::OnLButtonDown(nFlags, point); }
ratheeshnair123 wrote:
else { m_treeCtrl.Select(htItem, TVGN_DROPHILITE); }
Why would you do this if
htItem
isNULL
?"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius