Re:imagelist - getbitmap method
Quote
In article <96h4r8$d...@bornews.inprise.com>, Claude Wilson wrote:
> BTW, I find this syntax rather unusual for delphi.
> Every other compnent I know would do this the other way round through a
> function that returns the image.
By no means. Components that return an object when you call a method
usually return a reference to an internal object they maintain, they do not
create a *new* one to return. If they did there would be the thorny issue
of freeing this object: who has to do it? The caller, of course, but what
if you code the call like
canvas.Draw(x, y, someObj.GetBitmap(i));
If GetBitmap returned a new object here it would be orphaned. Such methods
are a perfect recipe for memory leaks and should be avoided unless there
explicit purpose is to act as a factory method (in which case they should
be named accordingly, e.g. CreateXYZ).
TImageLIst.GetBitmap does something else, it fills an existing bitmap
object you hand it with data, it does not create a new Tbitmap object. So
the syntax of the method is perfectly appropriate.
Peter Below (TeamB) 100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!
Note: I'm unable to visit the newsgroups every day at the moment,
so be patient if you don't get a reply immediately.