News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

TreeView expand root

Started by ragdog, December 10, 2018, 02:44:02 AM

Previous topic - Next topic

ragdog

Hello @All

I try to expand a root treeview item by a single click, but it works not.
Have any an idea or better solution?


.elseif (([edi].NMHDR.code)==NM_CLICK)
PrintText "NM_CLICK"
mov eax,(NM_TREEVIEW ptr[edi]).itemNew.hItem
invoke SendMessage,hWnd,TVM_EXPAND,TVE_EXPAND,eax
PrintDec eax


And is it possible to check with  WM_NOTIFY if a root item expanded or collapsed?

Greets,

ragdog

Hello

I have today try this way it works but not always .

.elseif uMsg == WM_NOTIFY
mov edi,lParam
.if (([edi].NMHDR.code)==NM_CLICK)
mov tvi.imask,TVIF_HANDLE OR TVIF_STATE
mov tvi.stateMask,TVIS_EXPANDED
mov eax,(NM_TREEVIEW ptr[edi]).itemNew.hItem
mov tvi.hItem,eax
invoke SendMessage,hTreeView,TVM_GETITEM,0,addr tvi

and tvi.state,TVIS_EXPANDED
mov eax,tvi.state
PrintDec eax

.IF tvi.state & TVIS_EXPANDED
PrintText "expanded"
invoke SendMessage,hTreeView,TVM_EXPAND,TVE_COLLAPSE,(NM_TREEVIEW ptr[edi]).itemNew.hItem
mov tvi.state,0
mov tvi.imask,TVIF_HANDLE OR TVIF_STATE
mov tvi.stateMask,TVIS_EXPANDED
invoke SendMessage,hTreeView,TVM_SETITEM,0,addr tvi
invoke TreeViewGetItemText,hTreeView,(NM_TREEVIEW ptr[edi]).itemNew.hItem,addr buffer,256
invoke MessageBox,hWnd,addr buffer,0,0
.else
PrintText "collapsed"
invoke SendMessage,hTreeView,TVM_EXPAND,TVE_EXPAND,(NM_TREEVIEW ptr[edi]).itemNew.hItem
mov tvi.state,TVIS_EXPANDED
mov tvi.imask,TVIF_HANDLE OR TVIF_STATE
mov tvi.stateMask,TVIS_EXPANDED
invoke SendMessage,hTreeView,TVM_SETITEM,0,addr tvi
invoke TreeViewGetItemText,hTreeView,(NM_TREEVIEW ptr[edi]).itemNew.hItem,addr buffer,256
invoke MessageBox,hWnd,addr buffer,0,0
.endif
.endif

Has anyone have an idea or solution?

HSE

Hi Ragdog!

You only need one click in the node ("+")
Equations in Assembly: SmplMath

ragdog

Hello

I have a Treeview without Style Tvs_Hasbutton and Tvs_Haslines

fearless


    mov edi,lParam
    .if (([edi].NMHDR.code)==NM_CLICK)
        Invoke SendMessage, hTreeView, TVM_GETNEXTITEM, TVGN_CARET, NULL
        .IF eax != -1
            Invoke SendMessage, hTreeView, TVM_EXPAND, TVE_TOGGLE, eax
        .ENDIF


ragdog

Thank you Fearless

Your solution works well if you expand an item.
If you want to reduce one you need a current focus (double click).

This solution works good or have you an better idea?


mov edi,lParam
.if (([edi].NMHDR.code)==NM_CLICK)
invoke GetCursorPos, addr tvhit.pt
invoke ScreenToClient, hTreeView, addr tvhit.pt
mov tvhit.flags, TVHT_ONITEM
invoke SendMessage, hTreeView, TVM_HITTEST, 0, addr tvhit
invoke SendMessage, hTreeView, TVM_EXPAND, TVE_TOGGLE, eax
.endif


Greets

ragdog

Hello

I debug my Treeview code with a debugger

by [edi].nmcd.uItemState get i 0x51 if i focus on a root item.

I have search on Windows7 Sdk on CDIS_ states i cannot found any state with 0x51
Can any tell what 51 is?

fearless

https://docs.microsoft.com/en-us/windows/desktop/controls/tvm-getitemstate
Im guessing is a combination of states (OR'd together)

https://docs.microsoft.com/en-us/windows/desktop/Controls/tree-view-control-item-states

But your mentioning custom draw states (nmcd), so they are probably states that are OR'd together as well:
CDIS_SELECTED           equ 0001h
CDIS_GRAYED             equ 0002h
CDIS_DISABLED           equ 0004h
CDIS_CHECKED            equ 0008h
CDIS_FOCUS              equ 0010h
CDIS_DEFAULT            equ 0020h
CDIS_HOT                equ 0040h
So probably 0x51 = CDIS_HOT or CDIS_FOCUS or CDIS_SELECTED