[lazarus] CheckListBox can't store objects with items in win32 interface

Marc Weustink marc at dommelstein.net
Sun Dec 7 12:30:03 EST 2003


At 10:47 7-12-2003, Vincent Snijders wrote:
>Hi,
>
>While trying to get the debug options dialog working, I noticed that the
>win32 interface doesn't store the objects associated with a list item
>in a CheckedListBox (or ListBox).
>
>While implementing this the obvious way with LB_SETITEMDATA. This works
>for TListBox, but not for TCheckListBox, because TCheckListBox stores it
>Checked property in the item data.

Yep.

>Any suggestions to solve this? Storing a heap-allocated record with
>object and selected fields in the item data is one possibility, but I
>fear the bookkeeping involved. Any suggestions are wellcome.

I had the samme problem when I introduced the CheckList. Delphi uses the 
TCheckListBoxDataWrapper class to handle this. We can do it the same way, 
but like you said, you need some bookkeeping.
Another way is to move the checkstate to the interface, so that Item.Dat is 
just userdata. The TCheckListBoxDataWrapper class isn't published, so I 
have no problems with that.

Marc






More information about the Lazarus mailing list