heya,
lately i have added an tree control to my small app ( read and learned from icezelion's tutorial and example ).
the problem i am facing now is that the Tree control switch between the paret/root trees when i select them with the WM_CLICK , but
it doesn't work when i try to use the WM_RCLICK msg,
if i hold down the right button, it select the item, but when i leave the button, the last item that has been selected with the click is now set .
you can see this effect in icezelion's example too,
can someone help me with it or have any trick to fix it?
thnx Wizz
Posted on 2003-01-24 18:46:58 by wizzra
i think that is normal behavior, even windows explorer does that... lets say your copying files and u wanna right click-paste those files into another folder... u dont want the currently selected folder to change when doing that. But to change this it seems like you could just add some handler code to the wm_rbuttonup msg that just changes the index..
Posted on 2003-01-24 20:32:17 by BubbaFate
change the WM_NOTIFY handler in Iczelion's example to this...

    [COLOR=blue].elseif[/COLOR][COLOR=gray]([/COLOR]uMsg [COLOR=gray]==[/COLOR] WM_NOTIFY[COLOR=gray])[/COLOR]

[B]mov[/B] [COLOR=magenta]edi[/COLOR][COLOR=gray],[/COLOR] lParam
[COLOR=blue]assume[/COLOR] [COLOR=magenta]edi[/COLOR][COLOR=gray]:[/COLOR][COLOR=blue]ptr[/COLOR] NM_TREEVIEW
[COLOR=blue].if[/COLOR][COLOR=gray]([[/COLOR][COLOR=magenta]edi[/COLOR][COLOR=gray]].[/COLOR]hdr[COLOR=gray].[/COLOR]code [COLOR=gray]==[/COLOR] TVN_BEGINDRAG[COLOR=gray])[/COLOR]
[COLOR=blue]invoke[/COLOR] SendMessage[COLOR=gray],[/COLOR] hwndTreeView[COLOR=gray],[/COLOR] TVM_CREATEDRAGIMAGE[COLOR=gray],[/COLOR] [COLOR=red]0[/COLOR][COLOR=gray], [[/COLOR][COLOR=magenta]edi[/COLOR][COLOR=gray]].[/COLOR]itemNew[COLOR=gray].[/COLOR]hItem
[B]mov[/B] hDragImageList[COLOR=gray],[/COLOR] [COLOR=magenta]eax[/COLOR]
[COLOR=blue]invoke[/COLOR] ImageList_BeginDrag[COLOR=gray],[/COLOR] hDragImageList[COLOR=gray],[/COLOR] [COLOR=red]0[/COLOR][COLOR=gray],[/COLOR] [COLOR=red]0[/COLOR][COLOR=gray],[/COLOR] [COLOR=red]0[/COLOR]
[COLOR=blue]invoke[/COLOR] ImageList_DragEnter[COLOR=gray],[/COLOR] hwndTreeView[COLOR=gray], [[/COLOR][COLOR=magenta]edi[/COLOR][COLOR=gray]].[/COLOR]ptDrag[COLOR=gray].[/COLOR]x[COLOR=gray], [[/COLOR][COLOR=magenta]edi[/COLOR][COLOR=gray]].[/COLOR]ptDrag[COLOR=gray].[/COLOR]y
[COLOR=blue]invoke[/COLOR] SetCapture[COLOR=gray],[/COLOR] hWnd
[B]mov[/B] DragMode[COLOR=gray],[/COLOR] TRUE
[COLOR=blue]assume[/COLOR] [COLOR=magenta]edi[/COLOR][COLOR=gray]:[/COLOR][COLOR=blue]ptr[/COLOR] NMHDR [COLOR=green]; treat edi as a NMHDR structure[/COLOR]
[COLOR=blue].elseif[/COLOR][COLOR=gray]([[/COLOR][COLOR=magenta]edi[/COLOR][COLOR=gray]].[/COLOR]code [COLOR=gray]==[/COLOR] NM_RCLICK[COLOR=gray])[/COLOR] [COLOR=green]; if this is a NM_RCLICK notification[/COLOR]
[COLOR=blue]invoke[/COLOR] SendMessage[COLOR=gray],[/COLOR] hwndTreeView[COLOR=gray],[/COLOR] TVM_GETNEXTITEM[COLOR=gray],[/COLOR] TVGN_DROPHILITE[COLOR=gray],[/COLOR] [COLOR=red]0[/COLOR] [COLOR=green]; get current drop hilited item[/COLOR]
[COLOR=blue].if[/COLOR][COLOR=gray]([/COLOR][COLOR=magenta]eax[/COLOR] [COLOR=gray]!=[/COLOR] [COLOR=red]0[/COLOR][COLOR=gray])[/COLOR] [COLOR=green]; if there is a drop hilited item[/COLOR]
[COLOR=blue]invoke[/COLOR] SendMessage[COLOR=gray],[/COLOR] hwndTreeView[COLOR=gray],[/COLOR] TVM_SELECTITEM[COLOR=gray],[/COLOR] TVGN_CARET[COLOR=gray],[/COLOR] [COLOR=magenta]eax[/COLOR] [COLOR=green]; select it[/COLOR]
[COLOR=blue].endif
.endif
assume[/COLOR] [COLOR=magenta]edi[/COLOR][COLOR=gray]:[/COLOR]nothing
Posted on 2003-01-24 22:11:50 by BubbaFate
Thnx BubbaFate,
it worked fine!! :alright:
Posted on 2003-01-25 02:09:47 by wizzra