[DUG] Assigned image to SpeedButton not transparent
Ross Levis
ross at stationplaylist.com
Fri Oct 30 15:51:56 NZDT 2015
Using D7/themes, I have a TSpeedButton which is a toggle and I need to
display 2 different glyphs in a TSpeedButton based on whether the button was
clicked or right-clicked, as they do 2 slightly different things.
So I need to assign a glyph to the button at run time, which works, but
nothing I do makes the image transparent. There is always a white square
with the icon in the middle. It only looks correct if I assign one of the
images to the Glyph property at design time.
I use a TImageList to store the 2 images, and assign them like this as
required.
BitMap := TBitMap.Create;
ImageList.GetBitmap(n,BitMap);
SpeedButton.Glyph := BitMap;
BitMap.Free;
where n is 0 or 1.
I've tried setting Bitmap.Transparent to true and other combinations like
TransparentMode and TransparentColor but nothing makes any difference.
There is some sort of transparency happening since the images have quite a
colorful background but this appears as white on the button.
As a test I assigned the image from a filename Button.Glyph.LoadFromFile()
and this works correctly and looks good, but I don't want to distribute BMP
files separately.
A possible alternative I haven't tried is embedding the 2 images as a
resource in the EXE file and using Button.Glyph.LoadFromResourceName (or
ResourceID), but that seems a lot of work. I thought I would try here to
see if anyone knows how to resolve the current method.
Cheers,
Ross.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserver.123.net.nz/pipermail/delphi/attachments/20151030/bc461c14/attachment.html
More information about the Delphi
mailing list