CompuServe Thread

Checked listbox

5 messages in this thread
#30289From: Mark WoodardJul 8, 1994 11:46 AM
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
#30461From: Jan VandenboschJul 11, 1994 12:26 AM
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
#30604From: MichTronJul 11, 1994 10:13 PM
Sheesh, you guys like you work hard! LButtonDown hit testings, etc…. Just make an OwnerDraw MultiSelection listbox… -tim
#30627From: Jan VandenboschJul 12, 1994 2:09 AM
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
#30680From: Mark WoodardJul 12, 1994 11:33 AM
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