Running Lazarus v1.0.12 under Win32, I am trying to add a Bitmap to a TImageList but I cannot get it transparent.
First I create a new bitmap using:
procedure FillBitmapCanvas(Bitmap: TBitmap; CanvasHeight, CanvasWidth: Integer;
CanvasColor, FrameColor: TColor; FrameSize: Integer);
begin
with Bitmap do
begin
Height := CanvasHeight;
Width := CanvasWidth;
Canvas.Brush.Color := CanvasColor;
Canvas.Pen.Color := FrameColor;
Canvas.Pen.Width := FrameSize;
Canvas.Rectangle(Rect(0, 0, Bitmap.Width, Bitmap.Height));
end;
end;
Then I add it to the Imagelist like so:
procedure AddToImageList(ImageList: TImageList);
var
_TransColor: TColor;
Bitmap: TBitmap;
begin
_TransColor := clFuchsia;
Bitmap := TBitmap.Create;
try
Bitmap.Transparent := True;
Bitmap.TransparentMode := tmFixed;
Bitmap.TransparentColor := _TransColor;
FillBitmapCanvas(Bitmap, ImageList.Height, ImageList.Width, _TransColor, _TransColor, 0);
ImageList.AddMasked(Bitmap, _TransColor);
finally
Bitmap.Free;
end;
end;
When I assign this image to a node in a Treeview it shows as solid pink square, when really I should not see it at all (unless it has other non fuchsia pixels on it).
What do I need to change to get it working?
Thanks.