Board index » delphi » imagelist - getbitmap method

imagelist - getbitmap method

Hello:
I would like to find a method of ImageList that I could use to do the
following :

MyBitButton.Glyph := MyImageList.aMethodToGetImage(imageindex);

I tried to use getimage but for some reason I can't get this to work.

Any hints appreciated.

-C.

 

Re:imagelist - getbitmap method


Claude, this should work for you.  regards Bill

ImageList1.GetBitmap(0, BitBtn1.Glyph);

Quote
"Claude Wilson" <cwil...@wcom.com> wrote in message

news:96emsb$k8913@bornews.inprise.com...
Quote
> I would like to find a method of ImageList that I could use to do the
> following :

> MyBitButton.Glyph := MyImageList.aMethodToGetImage(imageindex);

> I tried to use getimage but for some reason I can't get this to work.

> Any hints appreciated.

Re:imagelist - getbitmap method


Thanks Bill !
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.

Quote
"BillB" <bi...@catoctinsoftware.com> wrote in message

news:3a8b3e81_1@dnews...
Quote
> Claude, this should work for you.  regards Bill

> ImageList1.GetBitmap(0, BitBtn1.Glyph);

> "Claude Wilson" <cwil...@wcom.com> wrote in message
> news:96emsb$k8913@bornews.inprise.com...
> > I would like to find a method of ImageList that I could use to do the
> > following :

> > MyBitButton.Glyph := MyImageList.aMethodToGetImage(imageindex);

> > I tried to use getimage but for some reason I can't get this to work.

> > Any hints appreciated.

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.

Other Threads