Jump to content
Sign in to follow this  
daslick

treeview

Recommended Posts

daslick

Opt("GUIDataSeparatorChar","\")
MsgBox(0,'menu item clicked',_GUICtrlTreeView_GetTree($tree,_GUICtrlTreeView_GetSelection($tree)))

this should return the treeview's path to the right clicked item, right?

Ie: C:\path\itemclicked

But it you left clicked on 'path' in order to get to 'itemclicked' and you didn't left click on 'itemclicked' before right clicking, then it returns 'C:\path'

Does anyone know a solution for this?

Share this post


Link to post
Share on other sites
spudw2k

Opt("GUIDataSeparatorChar","\")
MsgBox(0,'menu item clicked',_GUICtrlTreeView_GetTree($tree,_GUICtrlTreeView_GetSelection($tree)))

this should return the treeview's path to the right clicked item, right?

Ie: C:\path\itemclicked

But it you left clicked on 'path' in order to get to 'itemclicked' and you didn't left click on 'itemclicked' before right clicking, then it returns 'C:\path'

Does anyone know a solution for this?

Perhaps this thread can shed some light on the subject.

http://www.autoitscript.com/forum/index.php?showtopic=84040

Share this post


Link to post
Share on other sites
daslick

Thank you!

This did it for me!

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam)
    Local $hWndTreeView, $tNMHDR, $hWndFrom, $iCode
    $hWndTreeView = $tree
    If Not IsHWnd($hWndTreeView) Then $hWndTreeView = GUICtrlGetHandle($hWndTreeView)
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndTreeView
            Switch $iCode
                Case $NM_DBLCLK
                    TreeClick()
                Case $NM_RCLICK
                    Local $tPOINT = _WinAPI_GetMousePos(True, $hWndFrom)
                    Local $iX = DllStructGetData($tPOINT, "X")
                    Local $iY = DllStructGetData($tPOINT, "Y")
                    Local $hItem = _GUICtrlTreeView_HitTestItem($hWndFrom, $iX, $iY)
                    If $hItem <> 0 Then _GUICtrlTreeView_SelectItem($hWndFrom, $hItem, $TVGN_CARET)
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×