Mega Code Archive

 
Categories / Delphi / Graphic
 

Change bitmap at runtime

Title: Change bitmap at runtime 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&ltImageList1.Count then ImageList1.GetBitmap(N,Image); BitBtn1.Glyph.Assign(Image); Inc(N); if N&gtImageList1.Count then N:=0; Image.Free; end;