On Fri, 12 May 2006 13:47:00 -0300
Andreas Berger <[EMAIL PROTECTED]> wrote:

> Andreas Berger wrote:
> 
> > I am porting an application from Delphi that depends heavily on images 
> > added at runtime to a TImageList. However, the Add method does not 
> > seem to work in Lazarus. Here is an example:
> >
> >    normalImages := TImageList.Create(AOwner);
> >    normalImages.Height := 33;
> >    normalImages.Width := 33;
> >    normalImages.Masked := false;
> >    . . .
> >    image := TBitmap.Create;
> >    image.LoadFromFile(f);
> >    currImages.Add(image, Nil);
> >    . . .
> >    normalImages.GetBitmap(baseImage * uc_NumOptions + imageIndex, 
> > image.Picture.Bitmap);   // This copies nothing into image
> >
> > It also does not work if I place a TImageList on a form and add the 
> > images (as above) at runtime. However, if I place a TImageList on the 
> > form  and store the images into it via the object inspector then the 
> > above line works ok. I assume that the Add function does not work 
> > correctly.
> >
> > Andreas
> 
> Ok I found the problem. Lazarus simply adds the image to the list 
> without making a copy, so when I deleted the image after adding it (like 
> is done in delphi) the image vanished :) . Is this an error?

Sorry for the late response.
There AddCopy and AddDirect methods. At the moment Add calls AddDirect.
Delphi's TImageList uses for historical reasons one image for the whole list
and has therefore no AddDirect. The whole Lazarus code uses AddDirect and
never AddCopy, so it seems Add as AddCopy is a Delphi atavism.
I asked on the devel list if we should change it - no response so far. It's
a difficult decision.

Comments?

Mattias

_________________________________________________________________
     To unsubscribe: mail [EMAIL PROTECTED] with
                "unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to