From: Nick Schultz on
I have a tree structure with multiple DSPs as parent nodes and their
reporting errors as the child node

for example:

|-DSP1
| |-error1
| |-error2
|
|-DSP2
|-error1
|-error2

I want to be able to have checkmarks to select DSPs only. However, if I
enable checkboxes, all items get a checkbox.

is there a way to just have the DSP items to have checkboxes?

Nick


From: Joseph M. Newcomer on
Short of doing it owner-draw, no idea.
joe

On Mon, 4 Aug 2008 14:42:53 -0700, "Nick Schultz" <nick.schultz(a)flir.com> wrote:

>I have a tree structure with multiple DSPs as parent nodes and their
>reporting errors as the child node
>
>for example:
>
>|-DSP1
>| |-error1
>| |-error2
>|
>|-DSP2
> |-error1
> |-error2
>
>I want to be able to have checkmarks to select DSPs only. However, if I
>enable checkboxes, all items get a checkbox.
>
>is there a way to just have the DSP items to have checkboxes?
>
>Nick
>
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
From: David Connet on
"Nick Schultz" <nick.schultz(a)flir.com> wrote in news:eACaNsn9IHA.4492
@TK2MSFTNGP03.phx.gbl:

> I have a tree structure with multiple DSPs as parent nodes and their
> reporting errors as the child node
>
> for example:
>
>|-DSP1
>| |-error1
>| |-error2
>|
>|-DSP2
> |-error1
> |-error2
>
> I want to be able to have checkmarks to select DSPs only. However, if I
> enable checkboxes, all items get a checkbox.
>
> is there a way to just have the DSP items to have checkboxes?

Yes. Enable the checkbox option and then manage all the setting of
checkboxes directly (do not use SetCheck). Checkmarks are managed using the
state attribute. So setting that to 0 will turn off the checkbox. (If I
remember, 1 == unchecked and 2 == checked - I'd have to look at the code to
verify)

Dave Connet
From: Nick Schultz on



"David Connet" <stuff(a)agilityrecordbook.com> wrote in message
news:IuZlk.17431$mh5.9752(a)nlpi067.nbdc.sbc.com...
> "Nick Schultz" <nick.schultz(a)flir.com> wrote in news:eACaNsn9IHA.4492
> @TK2MSFTNGP03.phx.gbl:
>
>> I have a tree structure with multiple DSPs as parent nodes and their
>> reporting errors as the child node
>>
>> for example:
>>
>>|-DSP1
>>| |-error1
>>| |-error2
>>|
>>|-DSP2
>> |-error1
>> |-error2
>>
>> I want to be able to have checkmarks to select DSPs only. However, if I
>> enable checkboxes, all items get a checkbox.
>>
>> is there a way to just have the DSP items to have checkboxes?
>
> Yes. Enable the checkbox option and then manage all the setting of
> checkboxes directly (do not use SetCheck). Checkmarks are managed using
> the
> state attribute. So setting that to 0 will turn off the checkbox. (If I
> remember, 1 == unchecked and 2 == checked - I'd have to look at the code
> to
> verify)
>
> Dave Connet
it looks like there are only 7 states, none that deal with checkbox state:



TVIS_BOLD

TVIS_CUT

TVIS_DROPHILITED

TVIS_EXPANDED

TVIS_EXPANDEDONCE

TVIS_EXPANDPARTIAL

TVIS_SELECTED


From: Volker Enderlein on
Nick Schultz schrieb:
> I have a tree structure with multiple DSPs as parent nodes and their
> reporting errors as the child node
>
> for example:
>
> |-DSP1
> | |-error1
> | |-error2
> |
> |-DSP2
> |-error1
> |-error2
>
> I want to be able to have checkmarks to select DSPs only. However, if I
> enable checkboxes, all items get a checkbox.
>
> is there a way to just have the DSP items to have checkboxes?
>
> Nick
>
I did have exactly the same problem yesterday and this is what I came up
with from the MSDN documentation:

To set the checkbox state:

TVITEM tvi = {0};
tvi.mask = TVIF_HANDLE | TVIF_STATE;
tvi.hItem = hParentItem;
tvi.stateMask = TVIS_STATEIMAGEMASK;
tvi.state = INDEXTOSTATEIMAGEMASK(index);
m_wndTree.SetItem(&tvi);

where and index of 0 means not to show a check box, 1 means unchecked, 2
means checked.

To get the check box state:

TVITEM tvi = {0};

// Prepare to receive the desired information.
tvi.mask = TVIF_HANDLE | TVIF_STATE;
tvi.hItem = hItem;
tvi.stateMask = TVIS_STATEIMAGEMASK;

// Request the information.
m_wndTree.GetItem(&tvi);

// Return zero if it's not checked, or nonzero otherwise.
return ((BOOL)(tvi.state >> 12) -1);

BTW you have to construct the TreeCtrl with the TVS_CHECKBOXES style.

Hope that helps, Cheers Volker

--
Volker Enderlein
Tel: +49 (0)371 53119651 Institut f�r Mechatronik
Fax: +49 (0)371 53119699 Reichenhainer Strasse 88
email: volker(a)ifm.tu-chemnitz.de D-09126 Chemnitz