ImageList lazarus / 31-LCL ---------------------------------------------------------------------- JimKueneman · 2013-03-30 00:58 I want to create a controls (TImage) on my form so I can assign different images to them at run time out of a ImageList.  I thought it would be easy but I am not seeing how to do this easily (easy = not drawing them directly in OnPaint events).  Is there a way to simply assign the correct image to the TImage (or some other control). Thanks, Jim ---------------------------------------------------------------------- Blaazen · 2013-03-30 01:35 Hi, this works: Code: [Select]procedure TForm1.Image1Click(Sender: TObject); var aDetail: TThemedElementDetails;     aImagePos: TPoint;     aIndex: Integer; begin   aDetail:=ThemeServices.GetElementDetails(tbPushButtonNormal);   aImagePos:=Point(0, 0);   aIndex:=0;   Image1.Picture.Bitmap.SetSize(ImageList16.Width, ImageList16.Height);   ThemeServices.DrawIcon(Image1. Picture.Bitmap.Canvas, aDetail, aImagePos, ImageList16, aIndex); end;It doesn't have to be Image1Click, it can be anywhere. You need "Themes" in uses. Otherwise it is obvious: aIndex is index of image in ImageList, aImagePos is top-left corner, aDetail determines style (you can try "tbPushButtonDisabled", icon or image will be grayed). ---------------------------------------------------------------------- JimKueneman · 2013-03-30 14:41 This is Windows only though is it not? Jim ---------------------------------------------------------------------- Blaazen · 2013-03-30 14:59 Themes are cross platform. Definitely the code above works on Linux+Qt or GTK2. ---------------------------------------------------------------------- JimKueneman · 2013-03-30 16:35 Thanks for clarifying.  In the meantime I ended up creating this solution: Code: [Select]var   ImageIndex: Integer;   ImagePos: TPoint;   Bitmap: TBitmap; begin   case ConfigInfo.State of     ocs_Current : ImageIndex := 0;     ocs_Unknown : ImageIndex := 2;     ocs_Dirty   : ImageIndex := 1;   end;   Bitmap := TBitmap.Create;   Bitmap.Width := ImageList.Width;   Bitmap.Height := ImageList.Height;   ImageList.GetBitmap(ImageIndex, Bitmap);   StateImage.Picture.Graphic := Bitmap;   Bitmap.Free; Jim