In the attachment you will find a simple program that shows a listview control with the LVS_EX_CHECKBOXES extended style used. This causes the listview to put checkboxes before each item and this all works fine..

But the problem is that I want to disable some of the items, i.e. preventing the user to uncheck them. I've seen several more or less the same examples in C (most using MFC) and the solution should be really simple but it just doesn't work for me.

When the LVN_ITEMCHANGING notifcation message is handled, one can detect if an item's state has changed. According to the docs, a non-null return value from the handler should prevent the state change. However this doesn't work.

The state change is successfully detected, when you disable the first or second item, you will hear a sound but I just can't get the listview to disallow the state change.
Any ideas?

Posted on 2001-12-10 14:49:08 by Thomas
Since your listview is in a dialog box, you will have to set return value with SetWindowLong, like:

; make some noise :)
invoke MessageBeep, MB_OK
invoke SetWindowLong,hWnd,DWL_MSGRESULT,1
mov eax,1

returning 1 in eax is still necessary to indicate you have processed the message

Posted on 2001-12-11 06:32:54 by japheth
Thanks a lot, I didn't know that, I don't use dialog boxes much. :rolleyes:

Posted on 2001-12-11 13:19:39 by Thomas
Likewise ;)

This is exactly what I was struggling over as well... :alright:

Posted on 2003-08-16 21:19:06 by NaN