用ImageList的GetBitmap函数,如果我把用这种形式ImageList1.GetBitmap(3, BitBtn1.Glyph);能够取到,
但是如果是ImageList1.GetBitmap(3, bmp1);  //bmp1: TBitmap;  bmp1始终都是空的,这是什么原因呢???

解决方案 »

  1.   

    procedure TForm1.BitBtn1Click(Sender: TObject);
    var
      FBit: TBitmap;
    begin
      FBit := TBitmap.Create;
      try
        ImageList1.GetBitmap(0, FBit); // 你创建TBitmap了么?
        BitBtn1.Glyph.Assign(FBit);
      finally
        FBit.Free;
      end;
    end;
      

  2.   

    bmp1 要初始化的!~ 即bmp1 := TBitmap.Create; 
      

  3.   

    Glyph 是 BitBtn1 的 成员 所以 BitBtn1 Create 的 时候 也Create 了  Glyph 
    而你 自己定义的 bmp1  没 就 要你自己 Create 咯