1. Home
  2. Computing & Technology
  3. Delphi Programming

How to exchange Bitmap images between two TImageList components

By Zarko Gajic, About.com

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;
~~~~~~~~~~~~~~~~~~~~~~~~~

Delphi tips navigator:
» How to clear the graphics in a TImage control
« What does #13#10 stand for, in Delphi code?

More Delphi Programming Quick Tips
Explore Delphi Programming
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Coding Delphi Applications
  5. Delphi Tips and Tricks
  6. 2005 Delphi Tips
  7. How to exchange Bitmap images between two TImageList components

©2009 About.com, a part of The New York Times Company.

All rights reserved.