Win32 API Select tree view entry by right clicking
Is that possible? I want to be able to right click on any entry and having that right click selecting the entry. Isn't that how like every other windows app works?
AFAIK the default behaviour of tree controls on a right click is to set the clicked item visually as selected, but on button up selected the original item(s) again.
If you want to change that behaviour you need to override PreTranslateMessage (MFC) or subclass the treeview control (WIN32).
If you want to change that behaviour you need to override PreTranslateMessage (MFC) or subclass the treeview control (WIN32).
AFAIK, it isn't default behaviour.
The MSDN indicates that when the Tree View control receives a right click, it sends a NM_RCLICK notification (in a WM_NOTIFY) to its parent window.
You could listen for this message and process it with something like this in your parent window's message hander:
The MSDN indicates that when the Tree View control receives a right click, it sends a NM_RCLICK notification (in a WM_NOTIFY) to its parent window.
You could listen for this message and process it with something like this in your parent window's message hander:
case WM_NOTIFY: { LPNMHDR pNMHDR = reinterpret_cast<LPNMHDR>(lParam); if(pNMHDR->hwndFrom == hTreeView && pNMHDR->code == NM_RCLICK) { HTREEITEM hItem = TreeView_GetNextItem(pNMHDR->hwndFrom, 0, TVGN_DROPHILITE); if(hItem) TreeView_SelectItem(pNMHDR->hwndFrom, hItem); } break; }
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement