Re:D2 ListBox 'ItemData' Property (like VB)
Quote
In article <01bbbbd2$63f5ccc0$572537a6@beta> "Mike Cookson" <mcook...@internetMCI.com> writes:
>From: "Mike Cookson" <mcook...@internetMCI.com>
>Subject: D2 ListBox 'ItemData' Property (like VB)
>Date: 17 Oct 1996 02:24:48 GMT
>There doesn't seem to be an 'ItemData' property for Delphi's ListBox
>component (like VB's, which exposes the 32bit value available via the
>LB_SETITEMDATA and LB_GETITEMDATA messages).
>There is, however, an array of TObjects associated with the ListBox, one
>per item (which can only store objects, not simple integer values)
it actually stores a 4 byte pointer, so you can typecast things into the
objects eg
var
anothernumber, anumber : longint;
alistbox :tlistbox;
begin {create the listbox elsewhere}
alistbox.items.addobject('A longint', tobject(anumber));
{should work}
anothernumber := longint(alistbox.items.objects[X});
Quote
>Does anyone know if the TObjects array uses the same 32bit storage area as
>that area available via the LB_SET/GET messages? IOW, is it safe for me to
>use the LB_SET/GET messages to store my own 32bit values related to each
>listbox item without Delphi thinking that they are TObject pointers or
>something?
dunno & don't recommend mixing your metaphors - imho Delphi has a fine
interface for these objects, so why bother with messages ?
Quote
>Finally, is there a better way to duplicate VB's 'ItemData' functionality
>in D2?
if you were feeling v energetic, you could derive a new listbox class, and
give this a published property, of whatever name you wanted. Some coding
needed, but not that much
HTH
Boris Ingram, Cyborg Software
boris...@iafrica.com
100076.3...@compuserve.com
http://www.pcb.co.za/users/borising/cyborg.htm