Title: How to exchange Bitmap images between two TImageList components
If you need to send a bitmap image from one TImageList component to another, you can use the next procedure (usage example below):
~~~~~~~~~~~~~~~~~~~~~~~~~
procedure ImageList_MoveBitmap(
const sourceImageList,
targetImageList: TImageList;
const sourcePosition: integer) ;
var
bitmap : TBitmap;
begin
bitmap := TBitmap.Create;
try
sourceImageList.GetBitmap(sourcePosition,bitmap) ;
targetImageList.Add(bitmap,nil) ;
sourceImageList.Delete(sourcePosition) ;
finally
bitmap.Free;
end;
end;
//Suppose two TImageList objects present on Form1
//Add Bitmap at position 7 from ImageList1 to the ImageList2
procedure TForm1.BitBtn1Click(Sender: TObject) ;
begin
ImageList_MoveBitmap(ImageList1, ImageList2, 7) ;
end;
~~~~~~~~~~~~~~~~~~~~~~~~~