DELPHI SPEEDBUTTON按钮动态加载图片(从IMAGE和IMAGELIST)

一、直接上代码

procedure TForm2.Button2Click(Sender: TObject);
var
  bmp: Tbitmap;

  Stream: TMemoryStream;
begin
  bmp := Tbitmap.Create;
  // ImageList1.GetBitmap(1, bmp); // IMAGELIST转
  // Image1.Picture.Assign(bmp); // IMAGE转
  Stream := TMemoryStream.Create;
  Image1.Picture.SaveToStream(Stream); // IMAGE控件转流
  // bmp.SaveToStream(Stream); //
  Stream.Position := 0;
  SpeedButton1.Glyph.LoadFromStream(Stream); // 从流加载
  Stream.Free;
  bmp.Free;
end;

 

你可能感兴趣的:(delphi,windows)