A customer was using the
extended listview style to get checkboxes for the listview items.
However, they also wanted some items to have a disabled checkbox,
which is not a feature that
They solved the problem by turning off the
style and replicating and extending the functionality of
custom state imagelist consisting of enabled and disabled and
checked and unchecked check boxes
and setting that as the state imagelist for the listview.
They also handled the mouse and keyboard notifications so that
clicking on the state image or pressing the space bar toggled
the check/unchecked state of the item.
So far so good.
However, there is still the issue of accessibility:
Accessibility tools understand that
style means that the state images are check boxes,
but since they aren't using that style, that leaves accessibility
tools in the dark.
How do they get accessibility tools the information they need?
One way is to subclass the listview control and customize the
GETOBJECT message handler
by wrapping the standard accessible object for the listview,
and then override the
accState method to report the
state for each item.
Alternatively, they can use Dynamic Annotation to report the state for the item. Direct Annotation is a push model, where the control pushes the current state each time it changes. Server Annotation is a pull model, where the control registers a server that produces the state of each item upon request. (Here's an example for a custom control.)
The customer chose to go with Dynamic Annotation and reported that it solved their problem.