Checked listbox
5 messages in this thread
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
Hi Mark,
thanks for the answer but you answered to my reply to Ed (Pinpoint, 76244,123)
he was posting the original question about a listbox containing checkboxes.
Jan
Sheesh, you guys like you work hard! LButtonDown hit testings, etc…. Just
make an OwnerDraw MultiSelection listbox…
-tim
Tim,
> Sheesh, you guys like you work hard!
no, no, certainly not with this kind of weather!! <BG>
> LButtonDown hit testings, etc….
> Just make an OwnerDraw MultiSelection listbox…
yes, yes, i know, but why is everybody answering to _me_ (not that i don't
value it when someone posts me a note ;-), i only just made the suggestion to
use the owner drawn listbox as a reply to Ed's question. Is CIS screwing up
this thread or is CsNav cheating on me :-S
Jan
Jan,
>thanks for the answer but you answered to my reply to Ed (Pinpoint, 76244,123)
he was posting the original question about a listbox containing checkboxes.
Sorry, Jan. Maybe CIS screwed up, or maybe WinCIM left off the part of your
reply that identified it as a reply.
Mark