From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to dim a tree item?

Solved!
Go to solution

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?

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
0 Kudos
Message 1 of 11
(5,976 Views)

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.

0 Kudos
Message 2 of 11
(5,974 Views)

Actually, I just tried it out and it didn't work.  Guess I'll have to think about it some more.

0 Kudos
Message 3 of 11
(5,969 Views)

I think that the reason is that the check mark is not part of any cell

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
0 Kudos
Message 4 of 11
(5,967 Views)

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;
}

 

 

Message 5 of 11
(5,965 Views)
Solution
Accepted by vix

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;
}

 

 

 

Message 6 of 11
(5,957 Views)

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

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
0 Kudos
Message 7 of 11
(5,944 Views)

I've just written a new product suggestion.

Feel free to give kudos if you think it's an useful feature Smiley Wink

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
Message 8 of 11
(5,932 Views)

Good suggestion. This issue has been reported to the development team. The ID is 298790.

0 Kudos
Message 9 of 11
(5,922 Views)

CAR 298790 has been fixed in CVI 2012

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV from 7
Using LW/CVI from 6.0
0 Kudos
Message 10 of 11
(5,630 Views)