下面是一个使用它的方法的例子,使用
TBitmap
TImageList
并在运行时将其放入glyph中。在这个例子中
TBitBtn->OnClick
事件处理程序。
void __fastcall TForm1::btn1Click(TObject *Sender)
{
// FOdd is a bool variable defined in the form's private section.
// It's just being used here as a toggle to flip between the images
this->FOdd = !this->FOdd;
TBitmap *bmp = new Graphics::TBitmap();
try {
bmp->SetSize(this->ImageList1->Width, this->ImageList1->Height);
this->ImageList1->GetBitmap(int(FOdd), bmp);
this->BitBtn1->Glyph->Assign(bmp);
}
__finally
{
delete bmp;
}
}