Jump to content

An event for treeview checkbox check ?


Recommended Posts


I am struggling in merging GUITreeViewEx, Shelltristate and enhancing to handle a third state that means : some items under are selected.

I have difficulties handling expand order and key Space (especially when node is collapsed).

Here the zip with UDF and and example.


The problem I might need some advice to handle : 

1- When load Treeview, have a correct settings of the checkbox for a tristate tree
2 - Handle keyboard used for walking in tree
     Chicken is checked and  Steak is unchecked
    When walking with arrow to Meat, it gets unchecked
3 - When node is collapsed and checked thru keyboard (space)
   the middle state is possible which should not

Here is joined an animated gif showing the 3 problems


Thanks for your advices














Link to comment
Share on other sites

You have to catch TVN_ITEMCHANGED notification in WM_NOTIFY event and test NewState/OldState change

See here for API reference




It's similar to ListView with checkboxes where is LVN_ITEMCHANGED notification event where AutoIt's code looks like this:

GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")

Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
    #forceref $hWndGUI, $MsgID, $wParam
    Local $tagNMHDR, $event

    $tagNMHDR = DllStructCreate("int;int;int", $lParam)
    $event = DllStructGetData($tagNMHDR, 3)

    If $hWndGUI = $Form1 And $wParam = $ListView1 And $disable_refresh_status = False Then
        If $event = $LVN_ITEMCHANGED Then
            $NMLISTVIEW = DllStructCreate($tagNMLISTVIEW, $lParam)
            If BitAND(DllStructGetData($NMLISTVIEW, "Changed"), $LVIF_STATE) = $LVIF_STATE And _
                DllStructGetData($NMLISTVIEW, "NewState") <> DllStructGetData($NMLISTVIEW, "OldState") Then MyFunction()




Search this forum for  TVN_ITEMCHANGED / LVN_ITEMCHANGED for more examples ...

Edited by Zedna
Link to comment
Share on other sites

  • 1 month later...


I am back with my adaptation to build an UDF for Tristate Treevew that automaticly update itself based on child selection.

You can play with GUITreeViewEx_Example_Loop.au3 to get a glimpse.


But I encountered a difference between x86 and x64. To noticed the difference (step to reporduce)
 - select item Meat (with mouse)
 - use space to select multiple time the value. on x86 the propagation occurs correctly; on  x64 you see the three possible state of the check box.


I think, I narrow it down to the structure $tagNMTVKEYDOWN. thru x64 it is not correctly populated (vkey is not set).


Tell me if I wrong. Any possible fix ?





Link to comment
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

  • Create New...