The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: egons on May 19, 2011, 11:01:30 AM

Title: get treeview node after right click
Post by: egons on May 19, 2011, 11:01:30 AM
how do i get node after user mouse button  right click?
Title: Re: get treeview node after right click
Post by: fearless on May 19, 2011, 11:23:34 AM
NM_RCLICK http://msdn.microsoft.com/en-us/library/bb773484%28v=vs.85%29.aspx which uses NMHDR http://msdn.microsoft.com/en-us/library/bb775514%28v=vs.85%29.aspx

and then you can use TVM_GETNEXTITEM http://msdn.microsoft.com/en-us/library/bb773622%28v=VS.85%29.aspx with TVGN_CARET to get currently selected item

Not sure if the below code is 100% accurate, modified it based on a right click for a listview, which has similar messages, but should give you and idea how to proceed hopefully :D

.ELSEIF eax==WM_NOTIFY
mov edi,lParam
assume edi:ptr NMHDR
mov eax,[edi].hwndFrom
.if eax==hTreeview
mov eax, [edi].code
.if eax == NM_RCLICK ; right click popup
Invoke SendMessage, hTreeview , TVM_GETNEXTITEM, TVGN_CARET, 0

Title: Re: get treeview node after right click
Post by: egons on May 20, 2011, 07:24:23 AM
well, but... looks like mouse right click didn't move selection(caret) to new node :bdg
Title: Re: get treeview node after right click
Post by: egons on May 20, 2011, 09:37:15 AM
            invoke SendMessage,hwndTreeView,TVM_GETNEXTITEM,TVGN_DROPHILITE,0;TVM_SELECTITEM,TVGN_CARET,eax
; possible eax=0
            invoke SendMessage,hwndTreeView,TVM_SELECTITEM,TVGN_CARET,eax

pretty nice, eh?