MFC tree control highlight item selected by the keyboard ?
I have this old code in which I had:
Code:
void ModCTreeCtrl::OnLButtonDown(UINT nFlags, CPoint point)
{
UINT uFlags;
HTREEITEM htItem = this->HitTest(point, &uFlags);
if ((htItem != NULL) && (uFlags & TVHT_ONITEM)) this->Select(htItem, TVGN_DROPHILITE);
CTreeCtrl::OnLButtonDown(nFlags, point);
}
in a derived class from a CTreeCtrl , actually I don't remember why I needed this (I think it had something to do with selection that changed in the current version , any idea ?) , anyway for some reason this prevent the "blue" highlight of the selected item from happening when I change the selected item using arrow keys , any idea why does this happen and how to fix it ?
Whenever I change the selected item using arrow key it doesn't get automatically highlighted
Re: MFC tree control highlight item selected by the keyboard ?
See CTreeCtrl::Select documentation in MSDN.
Quote:
- TVGN_CARET Sets the selection to the given item.
- TVGN_DROPHILITE Redraws the given item in the style used to indicate the target of a drag-and-drop operation.
- TVGN_FIRSTVISIBLE Scrolls the tree view vertically so that the given item is the first visible item.
So, to set the selection to the given item, use TVGN_CARET flag or get rid of that code and let the tree control with its default behavior.