The below question discusses how inheritance chain between TButton and TBitBtn has changed, namely the introduction of a common ancestor, TCustomButton.
What happened to TBitBtn and TButton inheritance chain?
In the past, those who wanted graphics on their button would opt for a TBitBtn, as it offered usage of bitmap glyphs.
In more recent versions of Delphi, the standard TButton allows to specify a TImageList, for png / jpg support, while TBitBtn does not.
My (long-time) button subclass inherits from TBitBtn, and changing that would mean a potential application-wide button redesign. No time for that. I want the ability to migrate things over time, in baby steps, without deleting and re-creating buttons (chance to miss the migration of a property or an event). Optimally, pick a button, wipe its glyph, put a png in its imagelist, over.
Looking at the sources of VCL.Buttons and VCL.StdCtrls, the bulk of the work for ImageList, ImageIndex ... is done at the common ancestor, TCustomButton. TButton only publishes those properties to be used at design-time.
Great, I can simply make my TBitBtn subclass publish those same properties. The properties are now visible in the object inspector. I can select an imagelist component, even pick an image index from the available images.
And this is where things stop working: the selected image doesn't get displayed at design-time, nor at runtime. Assign a glyph, it gets displayed without any problems. I tried looking at other properties which may interfere in the painting of the png (maybe some kind of transparency option), in vain.
EDIT:
This link mentions that TBitBtn purposely disables the usage of ImageList in favor of its own drawing:
http://codeverge.com/embarcadero.delphi.graphics/tbitbtn-with-png-on-d2009/1077124
Nonetheless, any suggestions on how I can achieve my "baby steps" migration described above from bmp icons to png ones, as smoothly as possible?
Version info: 10.3.1
Thanks!
TBitBtn
andTButton
that will make your "baby steps" very hard. You see unlike standardTButton
which is always showing just one imageTBitBton
can actually contain up to four Glyphs stored in same image. These four images are used to show different state of the button (Up, Disabled, Clicked, Down). In order to draw the needed image it uses ImageList code to extract the needed Glyph from the provided image. This makes loading of image/s to TBitBtn from image list not possible. – SilverWariorTCustomButton
class which introduces additional properties to determine Image Index for different button states essentially allowing any Button to have multiple images for multiple states. – SilverWariorTButBtn
. Maybe the new changes toTCustomButton
will also help you simply the code of your custom buttons. – SilverWarior