I'm currently working with a component called TdsTaskBar, which intends to work like the TaskBar in windows, which means all opened windows (but now inside my application) are listed as buttons on the bottom of my application-window. This buttons are TSpeedButtons. Now I've changed the icons of my own windows, this icons get always displayed via the glyph of the SpeedButtons. The problem is, that the transparency isn't working.
I'm aware of the Transparency Color defined by the lower left corner pixel, but that's not my problem. The problem is, that transparent areas of the Glyphs show "random" image artifacts instead of the button-background, when changing the active window and then hovering over the buttons. This changes the background to the icon of the now active window, but with some distortion.
I have NO clue how this artifacts get there, but I'm sure that it doesn't come from the TdsTaskBar- / TdsTaskButton-Component, because I examined all the paint-relevant procedures.
Does someone have an idea how to solve this problem? I already thought about drawing the background myself, but therefore I'd need to know the actual button color(s) behind this Glyph, and that's another thing where I'm not sure about how to figure it out.
Here the code snippet for assigning the glyph, the drawing is handled by standard Vcl SpeedButton Code:
procedure TTaskBarButton.AssignGlyphIcon;
var
GlyphIcon: TIcon;
b: TBitmap;
begin
if TForm(owner).Icon.Empty then
GlyphIcon := Application.Icon
else
GlyphIcon := TForm(owner).Icon;
b := TBitmap.create;
try
b.Width := GlyphIcon.Width;
b.Height := GlyphIcon.Height;
b.Canvas.Brush.Color := b.TransparentColor; // This two lines were added by me
b.Canvas.FillRect(b.ClipRect); // so that the background of my "helper" bitmap is transparent, too
b.Canvas.Draw(0,0, GlyphIcon);
Glyph.Width := 16;
Glyph.Height := 16;
Glyph.Canvas.StretchDraw(Rect(0, 0, 16, 16), b);
finally
b.free;
end;
end;
Glyph
. I also don't really understand why you needb
. Finally, it looks like you are using images with alpha transparency. If so, why useTransparentColor
? – David Heffernan