The simplest way to change bitmap at runtime is to use Assign method. Keep in mind, that when a property is an object, it has memory associated with it.
The memory associated with the old value has to be freed, the new memory has to be allocated.
procedure TForm1.Button1Click(Sender: TObject); var Image: TBitmap; begin Image:=TBitmap.Create; if N<ImageList1.Count then ImageList1.GetBitmap(N,Image); BitBtn1.Glyph.Assign(Image); Inc(N); if N>ImageList1.Count then N:=0; Image.Free; end;
- More for developers