LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Tree Expand Collapse events

Solved!
Go to solution

Hello

 

I don't understand how EVENT_COLLAPSE and EVENT_EXPAND work on a tree control.

Using the following code

case EVENT_EXPAND:
  GetTreeItemAttribute (FL_TreeListPanel, TREE_LIST_LIST, eventData2, ATTR_COLLAPSED,   &FL_ItemCollapsed);  
   break;

 

FL_ItemCollapsed is equal to 1. I was expecting 0 because a click on the + expands the tree.

 

In fact I want to adjust the height of the tree control to the number of exposed items.

I could notice that with

GetTreeItemAttribute (FL_TreeListPanel, TREE_LIST_LIST, ItemIndex, ATTR_COLLAPSED, &FL_ItemCollapsed); 

 

FL_ItemCollapsed is equal to 0 only after the callback function is finished. So I'm wondering how I could handle this situation in the Callback function.

 

Best regards

 

0 Kudos
Message 1 of 3
(2,914 Views)
Solution
Accepted by topic author Bertrand_ENAC

As stated in the help, EVENT_EXPAND and EVENT_COLLAPSE are swallovable events: that means that you receive them before their effect realized, so that you can swallow them (i.e. abort them, do as if they didn't succeed). One possible solution to this problem is to PostDeferredCall a function so that it is executed after the expand/collapse event has terminated.

You can search treeevent example on your machine: there is a example of PostDeferredCall associated to EVENT_EDIT_MODE_STATE_CHANGE event.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 3
(2,906 Views)

Thank you for your quick and appropriate help

0 Kudos
Message 3 of 3
(2,899 Views)