Is it possible to load an image from a TImageList into a TTrayIcon at runtime? How? Is this a good idea? Or is there a more preferred method for changing the tray icon's image at runtime?
Tested on Windows with Lazarus 0.9.30.4 using an image list composed of translucent png images, it is possible by using a temporary bitmap:
var
Bmp: TBitmap;
begin
Bmp := TBitmap.Create;
try
ImageList1.GetBitmap(0, Bmp);
TrayIcon1.Icon.Assign(Bmp);
TrayIcon1.Show;
finally
Bmp.Free;
end;
I don't see anything wrong with assigning the icon from an image list image at run-time. Also see example at the component's wiki page for other possible implementations for assigning the icon at run-time.