Michael Van Canneyt wrote:
I don't consider storing a pointer in the tag is broken code, it was
considered the accepted way to maintain a pointer to your custom data
from a
standard control and there is often no simple alternative.
Accepted only because there was no other way.
The only correct way is to introduce an additional field 'UserData', of
type Pointer.
I think this is an excellent solution. Casting Tags to pointer is/was bad
practice anyway.
The Tag can still be used for association of user data with a component, but
then as an index to a lookup table which holds the actual pointer. That is a
portable solution (though it requires a little more memory and code). So adding
a UserData field will be helpful.
If we really want to save memory usage, we can even let a UserData (public)
property and the Tag (published) property use the same field. Tag will then be
an interface to the lowest 32 bits of a pointer field, which is simply
stored/read in a whole by UserData. But this is of course a hack which is more
likely to confuse programmers and cause problems in the future, so I wouldn't
particularly recommend it...
Regards,
Bram Kuijvenhoven
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel