Mega Code Archive

 
Categories / Delphi / Graphic
 

Use an Icon for a Glyph on a TBitBtn Delphi control with the help of TImageList

Title: Use an Icon for a Glyph on a TBitBtn Delphi control with the help of TImageList The TBitBtn Delphi control is a button control that can include a bitmap on its face. The Glyph property specifies the bitmap that appears on the bitmap button. By design, the Glyph property can only display BMP (Windows Bitmap) images. If you need to display an icon (ICO) file on a BitBtn, you can use the next trick: Drop a TImageList on a form. The TImageList (Win32 palette) represents a collection of same-sized images, each of which can be referred to by its index. Assign several icons to the ImageList. Do it by double-clicking on the ImageList control at design time and use the ImageList designer. Use the next code to draw the first two ICOns in he ImageList onto BitBtn1 and BitBtn2: ImageList1.GetBitmap(0, BitBtn1.Glyph) ; ImageList1.GetBitmap(1, BitBtn2.Glyph) ; That's all. Note how the TImageList control also exposes the GetIcon method you can use to obtain a particular image in the image list as an icon.