05-12-2011 02:54 AM
I have a tree control with check marks and the option "Text Click Toggles Mark".
When I have a list of items I need to disable (i.e. make dimmed) some of them, but I can't find the attribute ATTR_DIMMED for the function SetTreeItemAttribute().
I used SetTreeCellAttribute() but in this way the check marks remains active, so I can toggle it also for disabled items.
How can I completely disable (i.e. dim) a tree item? With its check mark too?
Solved! Go to Solution.
05-12-2011 08:39 AM - edited 05-12-2011 08:41 AM
Hi,
I had a different question about Tree controls a while back, but I think the solution might help you. Please see this thread:
http://forums.ni.com/t5/LabWindows-CVI/Tree-control-column-question-Hot-Indicator/m-p/1475142#M51587
Basically if you swallow the callback on EVENT_LEFT_CLICK for the cells the user shouldn't be able to edit, then the cells will act like indicators (user can't change anything). I believe this works for the marks too.
Hope this helps.
05-12-2011 08:46 AM
Actually, I just tried it out and it didn't work. Guess I'll have to think about it some more.
05-12-2011 08:48 AM
I think that the reason is that the check mark is not part of any cell
05-12-2011 08:55 AM
It looks like I was on the right track. The key is to swallow the callback for EVENT_MARK_STATE_CHANGE based upon whether the user is allowed to change the mark state or not. For example, this disallows the check box to be toggled for the 2nd item in the tree (tree index of 1) while the other items can still be toggled:
int CVICALLBACK TreeCB (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int swallowed = 0; switch (event) { case EVENT_MARK_STATE_CHANGE: if(eventData2 == 1) swallowed = 1; break; } return swallowed; }
05-12-2011 11:59 AM
This should do the trick.
int CVICALLBACK TreeCB (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int itemIdx, dimmed, swallow=0; switch (event) { case EVENT_MARK_STATE_CHANGE: itemIdx = eventData2; GetTreeCellAttribute(panel, control, itemIdx, 0, ATTR_CELL_DIMMED, &dimmed); if (dimmed) swallow = 1; break; } return swallow; }
05-13-2011 01:09 AM
I had already think about swallowing the EVENT_MARK_STATE_CHANGE event, but I wonder if is there a way to have the check box dimmed (i.e. grayed out).
In this way it's clear that it's not active
05-13-2011 07:01 AM
I've just written a new product suggestion.
Feel free to give kudos if you think it's an useful feature
05-13-2011 10:53 AM
Good suggestion. This issue has been reported to the development team. The ID is 298790.
09-13-2012 05:34 AM
CAR 298790 has been fixed in CVI 2012