From: Kinglemur on

I noticed while writing a handler for the NM_CUSTOMDRAW notification for
a CListCtrl that the NVLMCUSTOMDRAW structure passed to the handler contains
an NMCUSTOMDRAW struction, which contains a member variable uItemState.
Possible settings for this state include CDIS_GRAYED and CDIS_DISABLED, both
of which sound a lot like what I'd like to do to the state of some of my
items (in Icon View).

Is there any way to set a CListCtrl item's state to be disabled or
grayed? I'm currently setting the state to LVIS_CUT and the text color to
gray to represent a disabled item, which is not entirely satisfactory since
LVIS_CUT looks just like LVIS_SELECTED.

Thanks for any advice.

David
From: Tom Serface on
I would just change the color and then note in your program (probably in an
array that says whether the item is valid or not) that the value is not
useful so don't allow it to be selected. You could also display the
disabled items as "not selected" even though they may be in the
OnCustomDraw() routine, but checking your array of "states" so to speak.

Tom

"Kinglemur" <Kinglemur(a)discussions.microsoft.com> wrote in message
news:D014BD48-B16D-4135-9AD8-522D406B5313(a)microsoft.com...
>
> I noticed while writing a handler for the NM_CUSTOMDRAW notification for
> a CListCtrl that the NVLMCUSTOMDRAW structure passed to the handler
> contains
> an NMCUSTOMDRAW struction, which contains a member variable uItemState.
> Possible settings for this state include CDIS_GRAYED and CDIS_DISABLED,
> both
> of which sound a lot like what I'd like to do to the state of some of my
> items (in Icon View).
>
> Is there any way to set a CListCtrl item's state to be disabled or
> grayed? I'm currently setting the state to LVIS_CUT and the text color to
> gray to represent a disabled item, which is not entirely satisfactory
> since
> LVIS_CUT looks just like LVIS_SELECTED.
>
> Thanks for any advice.
>
> David

From: Joseph M. Newcomer on
I tend to store this in the ItemData of the list control. When I'm using custom draw,
that's a fairly rich structure, so adding a bit or BOOL for enable is no big deal. I try
to avoid the keep-an-array model when using controls; it's just too complex to keep the
array in sync with the control contents.
joe

On Thu, 8 Mar 2007 19:47:11 -0800, "Tom Serface" <tom.nospam(a)camaswood.com> wrote:

>I would just change the color and then note in your program (probably in an
>array that says whether the item is valid or not) that the value is not
>useful so don't allow it to be selected. You could also display the
>disabled items as "not selected" even though they may be in the
>OnCustomDraw() routine, but checking your array of "states" so to speak.
>
>Tom
>
>"Kinglemur" <Kinglemur(a)discussions.microsoft.com> wrote in message
>news:D014BD48-B16D-4135-9AD8-522D406B5313(a)microsoft.com...
>>
>> I noticed while writing a handler for the NM_CUSTOMDRAW notification for
>> a CListCtrl that the NVLMCUSTOMDRAW structure passed to the handler
>> contains
>> an NMCUSTOMDRAW struction, which contains a member variable uItemState.
>> Possible settings for this state include CDIS_GRAYED and CDIS_DISABLED,
>> both
>> of which sound a lot like what I'd like to do to the state of some of my
>> items (in Icon View).
>>
>> Is there any way to set a CListCtrl item's state to be disabled or
>> grayed? I'm currently setting the state to LVIS_CUT and the text color to
>> gray to represent a disabled item, which is not entirely satisfactory
>> since
>> LVIS_CUT looks just like LVIS_SELECTED.
>>
>> Thanks for any advice.
>>
>> David
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
From: Tom Serface on
Hi Joe,

I mostly only use virtual list controls so the "array" is the list of
objects that feed the control during the GetDispInfo handler. The data is
only stored once. If you are not doing a virtual list control (and I'm not
sure why you wouldn't) your method would really be better. So, the array is
already there, I just add an element to the item object with state
information.

Tom

"Joseph M. Newcomer" <newcomer(a)flounder.com> wrote in message
news:ukr2v2djhalr34qcpra3kjh5trk544qbh9(a)4ax.com...
>I tend to store this in the ItemData of the list control. When I'm using
>custom draw,
> that's a fairly rich structure, so adding a bit or BOOL for enable is no
> big deal. I try
> to avoid the keep-an-array model when using controls; it's just too
> complex to keep the
> array in sync with the control contents.
> joe

From: Joseph M. Newcomer on
Yes, in that case the array *is* the contents.
joe

On Fri, 9 Mar 2007 08:24:24 -0800, "Tom Serface" <tom.nospam(a)camaswood.com> wrote:

>Hi Joe,
>
>I mostly only use virtual list controls so the "array" is the list of
>objects that feed the control during the GetDispInfo handler. The data is
>only stored once. If you are not doing a virtual list control (and I'm not
>sure why you wouldn't) your method would really be better. So, the array is
>already there, I just add an element to the item object with state
>information.
>
>Tom
>
>"Joseph M. Newcomer" <newcomer(a)flounder.com> wrote in message
>news:ukr2v2djhalr34qcpra3kjh5trk544qbh9(a)4ax.com...
>>I tend to store this in the ItemData of the list control. When I'm using
>>custom draw,
>> that's a fairly rich structure, so adding a bit or BOOL for enable is no
>> big deal. I try
>> to avoid the keep-an-array model when using controls; it's just too
>> complex to keep the
>> array in sync with the control contents.
>> joe
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm