The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: DC on January 23, 2006, 01:22:56 AM

Title: Treeview item -> get handle?
Post by: DC on January 23, 2006, 01:22:56 AM
the only time I seem to get a handle for a treeview item is when it is selected or being selected...
is there a way to get the handle to one that is clicked and/or right-clicked selected or not?
        .elseif [edi].NMTREEVIEW.hdr.code == NM_RCLICK
            dec     fSel    ;   flag to bypass TVN_SELCHANGED
            invoke  GetCursorPos, addr mousePos
            m2m     tvhit.pt.x, mousePos.x  ;   [edi].NMTREEVIEW.ptDrag.x   ;   niether works
            m2m     tvhit.pt.y, mousePos.y  ;   [edi].NMTREEVIEW.ptDrag.y   ;      "      "
            m2m     tvhit.flags, TVHT_ONITEM
            invoke  SendMessage, hTV, TVM_HITTEST, 0, addr tvhit
            invoke  SendMessage, hTV, TVM_SELECTITEM, TVGN_CARET, tvhit.hItem
            invoke  LoadMenu, hInstance, IDI_TREEMENU
            invoke  GetSubMenu, eax, 0
            mov     hpum, eax
            invoke  GetCursorPos, addr mousePos
            invoke  TrackPopupMenu, hpum, TPM_LEFTALIGN or TPM_RIGHTBUTTON, mousePos.x, mousePos.y, 0, hTV, NULL
            invoke  DestroyMenu, hpum
            inc     fSel
        .endif

thanx,
DC
Title: Re: Treeview item -> get handle?
Post by: zooba on January 23, 2006, 03:21:16 AM
Is this what you want?

[edi].NMTREEVIEW.itemOld.hItem
[edi].NMTREEVIEW.itemOld.hItem
[edi].NMTREEVIEW.itemNew.hItem
Title: Re: Treeview item -> get handle?
Post by: DC on January 23, 2006, 03:31:37 AM
that gives me 'previously selected hItem', 'previously selected hItem', 'currently selected hItem'...
I want 'currently clicked hItem'
[edit]
clicking on all-ready selected items doesn't seem to varify that action,
right clicks don't seem to give up any hItem info either - selected or not
Title: Re: Treeview item -> get handle?
Post by: Tedd on January 23, 2006, 12:36:08 PM
Try this example..
The useful thing for you will be the TreeGetItemClicked function - which works wether or not the item has actually been clicked (but I only call it upon a click)


[attachment deleted by admin]
Title: Re: Treeview item -> get handle?
Post by: DC on January 24, 2006, 01:52:54 AM
ah,ha!
it was ScreenToClient that I was missing, sure would be nice to have a list of cool trick functions... like one I accidently stumbled on, I don't even know how...
PathAddBackslash - very nice function... alot of the cool ones I'm not even aware of...
anyway, this works now, thanx again Tedd
        .elseif [edi].NMTREEVIEW.hdr.code == NM_RCLICK
            dec     fSel    ;   flag to bypass TVN_SELCHANGED
            invoke  GetCursorPos, addr tvhit.pt
            invoke  ScreenToClient, hTV, addr tvhit.pt
            mov     tvhit.flags, TVHT_ONITEM
            invoke  SendMessage, hTV, TVM_HITTEST, 0, addr tvhit
            invoke  SendMessage, hTV, TVM_SELECTITEM, TVGN_CARET, eax ;   tvhit.hItem
            invoke  LoadMenu, hInstance, IDI_TREEMENU
            invoke  GetSubMenu, eax, 0
            mov     hpum, eax
            invoke  GetCursorPos, addr mousePos
            invoke  TrackPopupMenu, hpum, TPM_LEFTALIGN or TPM_RIGHTBUTTON, mousePos.x, mousePos.y, 0, hTV, NULL
            invoke  DestroyMenu, hpum
            inc     fSel
        .endif