Jump to content
  • Advertisement
Sign in to follow this  
Hannesnisula

Win32 API Select tree view entry by right clicking

This topic is 3338 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
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).

Share this post


Link to post
Share on other sites
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:

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;
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!