Jump to content
Sign in to follow this  

Help - Select item in treeview

Recommended Posts

Hello all,

i need help managing treeview.

In my script when i click on an item in my treeview the first click don't do anything.

The second one returns the result of the first click, the third returns the second selection and etc...

i have seen that the $NM_CLICK execute my function but before the action of selecting my tree object.

Can some one explain me the way to make my script run AFTER the selection action?


Global $TreeList = GUICtrlCreateTreeView(15, 50, 200, 270, $iStyle, $WS_EX_CLIENTEDGE)
Global $TreeView = GUICtrlGetHandle($TreeList)

GUIRegisterMsg($WM_NOTIFY, '_OnNotify')

Func _OnNotify($hWnd, $Msg, $wParam, $lParam)
    Local $tNMHDR, $hWndFrom, $iCode
        $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
        $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom")
        $iCode = DllStructGetData($tNMHDR, "Code")
        Switch $hWndFrom
        Case $TreeView
             Switch $iCode
                    Case $NM_CLICK
                          Local $tINFO = DllStructCreate($tagNMTREEVIEW, $lParam)
                          Local $hControl = DllStructGetData($tINFO, "NewhItem")
                          Local $sTVIsSelected =_GUICtrlTreeView_GetText($TreeList, _GUICtrlTreeView_GetSelection($TreeList))
                          ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sTVIsSelected = ' & $sTVIsSelected & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
              Return $GUI_RUNDEFMSG
EndFunc   ;==>_OnNotify
Edited by IceMaKeR

Share this post

Link to post
Share on other sites


Thanks for answering.

Yes the treeview creation is missing because i create it from an array dinamically.

you can use any data in treeview it causes the error.

I think that's my switch is the source of my problem too but can't find where!

Edited by IceMaKeR

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...