Checked listbox
08-Jul-94 11:46:46
Sb: #30142-Checked listbox
Fm: Mark Woodard 74750,70
To: Jan Vandenbosch 100316,2771
Jan,
I've recently done just what you arf asking about. I'm sorry I can't mail you
my code, but I can tell you how I did it.
Create a class derived from CListBox. When the listbox is created (either
dynamically or in AppStudio) give it the styles LBS_OWNERDRAWNFIXED and
LBS_HASSTRINGS. In the derived class, override MeasureItem and DrawItem.
In DrawItem, you draw a checkbox and the string to the right of it.
The way I determine if an item is checked is by using SetItemData and
GetItemData. I overrode OnLButtonDown to do some hit-testing, toggled the value
set with SetItemData, sent a custom notification message indicating that an
item had been checked or unchecked, then did the default processing.
That's about it! I had to handle a few other issues, since my Item Height was
based on the font. Hope this gets you started.
Mark