Mark Williams 14 Posted January 14, 2020 When using a dark theme with TButtonedEdit and an imagelist with DrawingStyle set to dsTransparent, the image always shows with a white background. That's obviously fine when the edit box is white, but not when it is dark. My images in the imagelist have a background colour of clFuschia. For some reason I can't change the transparent color in the imageList's editor. It is disabled and clDefault is selected. So I tried another approach, creating an imageList at runtime and adding masked images to it as follows: Function GetTransparentImageList(Owner:TComponent; SourceImages:TImageList; BMPIndex:Integer):TImageList; var bmp:TBitmap; begin bmp:=TBitmap.Create; try if SourceImages.GetBitmap(BMPIndex, bmp) then begin Result:=TImageList.Create(Owner); With Result do begin DrawingStyle:=dsTransparent; //tried with and without for all three color options below AddMasked(bmp, clNone); //tried with clFuchsia and clDefault end; end; finally bmp.Free; end; end; Still the TButtonedEdit stubbornly shows the button image with a white background. Am I missing something? Share this post Link to post
pyscripter 689 Posted January 14, 2020 https://quality.embarcadero.com/browse/RSP-26633 The report contains a solution. 1 Share this post Link to post
Mark Williams 14 Posted January 14, 2020 42 minutes ago, pyscripter said: https://quality.embarcadero.com/browse/RSP-26633 The report contains a solution. Thanks for the link. It didn't seem to work for me. However, it gave me the idea to change my function to repaint the background of the glyph. Now works and will have to do for now. Function GetTransparentImageList(Owner:TComponent; SourceImages:TImageList; BMPIndex:Integer):TImageList; var bmp:TBitmap; begin bmp:=TBitmap.Create; try if SourceImages.GetBitmap(BMPIndex, bmp) then begin Result:=TImageList.Create(Owner); With Result do begin bmp.Canvas.Brush.Color:=StyleServices.GetSystemColor(clWindow);; bmp.Canvas.FloodFill(0, 0, bmp.canvas.Pixels[0, 0], fsSurface); AddMasked(bmp, clFuchsia); end; end; finally bmp.Free; end; end; Share this post Link to post
GPRSNerd 12 Posted January 14, 2020 (edited) Check my older RSP, that has an easier workaround:https://quality.embarcadero.com/browse/RSP-24070 Just load the corresponding color again with StyleServices: be2.Color := StyleServices.GetSystemColor(be2.Color); Edited January 14, 2020 by GPRSNerd Share this post Link to post
Guest Posted May 13, 2020 Hi, I have same problem (but I use system image list), but I could not fix it. I tried all the solutions proposed in this topic, but they doesn't work. So I want to change TEditButton's paint method (so I can use proper color for TEditButton.TGlyph.Canvas.Brush.Color), but I don't know how. Can somebody help me? Thanks. Share this post Link to post
Guest Posted May 19, 2020 Resolved using @GPRSNerd's solution and clWindow (so change from "dark" theme to light, the background color of tbuttonededit is always right). Thanks. Share this post Link to post