delphi - TImageList.ShareImages - How to use exactly to not have to copy the content? -


i use c++ builder, question relevant delphi believe.

when have 2 timagelist objects , @ point want use same icons in both image lists, can copy content: imagelist2.assign(imagelist1) ;

however, noticed timagelist.shareimages in suggesting can use same internal list, , save resources copying !? poorly documented because i'm not sure how can achieve ? do make imagelist2 use same internal list imagelist1 ? (i set imagelist2.shareimages = true then.

as read source code, this:

imagelist2->handle = imagelist1->handle; imagelist2->shareimages = true; 

all shareimages controls whether or not image list handle owner list. in case owned imagelist1 , not imagelist2.

a consequence of imagelist1 must out live imagelist2. otherwise if imagelist1 destroyed first, imagelist2 left holding on handle of image list has been destroyed.


Comments