Custom panel - issue with parent color in childs lazarus / 31-LCL ---------------------------------------------------------------------- Dibo · 2012-12-05 15:34 Hi, I have own custom panel which inherit from TCustomControl instead of TCustomPanel (which inherit from TCustomControl also). Problem is that controls placed on my panel don't refresh parent color. See attached screen, top panel is my, bottom is standard TPanel. Both have color set to clBlack, but TEdit placed on my panel has gray background instead of black. I'm analyzing source of TCustomPanel and I'm stuck. I have the same flags etc. Have widgets hard coded check that parent for background color must inherit from TCustomPanel/TCustomForm? Regards ---------------------------------------------------------------------- howardpc · 2012-12-05 16:16 Quote from: Dibo on December 05, 2012, 04:34:35 pmProblem is that controls placed on my panel don't refresh parent color... TEdit placed on my panel has gray background instead of black. Not quite sure I understand your problem. The following short unit shows a blue Edit on a blue customPanel OK (on Windows). Code: [Select]unit Unit1; {$mode objfpc}{$H+} interface uses   Forms, Graphics, StdCtrls, extCtrls; type   TMyPanel = class(TCustomPanel)   end;   TForm1 = class(TForm)     procedure FormCreate(Sender: TObject);   private     myPanel: TMyPanel;     ed: TEdit;   end; var   Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.FormCreate(Sender: TObject); begin   myPanel:= TMyPanel.Create(Self);   myPanel.Parent:= Self;   myPanel.Color:= clSkyBlue;   ed:= TEdit.Create(Self);   ed.ParentColor:=True;   ed.Parent:= myPanel;   ed.Left:=10;   ed.Top:=10; end; end. ---------------------------------------------------------------------- Dibo · 2012-12-05 16:31 Yes, inheriting from TCustomPanel works fine (this is bottom panel on the screenshot), but I inherit from TMyPanel = class(TCustomControl) and my panel acts same as normal panel (can have childs etc) ---------------------------------------------------------------------- howardpc · 2012-12-05 16:39 Quote from: Dibo on December 05, 2012, 05:31:15 pmI inherit from TMyPanel = class(TCustomControl) and my panel acts same as normal panel (can have childs etc) Perhaps, then, you have not chosen the best ancestor for your component. If the functionality you need is already present in TCustomPanel, why not descend from that? ---------------------------------------------------------------------- Dibo · 2012-12-05 16:44 I don't want use ExtCtrls unit ---------------------------------------------------------------------- FelipeFS · 2012-12-05 16:55 Does TMyPanel uses the color property from TCustomControl or did you created a new property for color? ---------------------------------------------------------------------- Dibo · 2012-12-05 16:56 It is using color from TCustomControl. I just published it to get it in object inspector ---------------------------------------------------------------------- Blaazen · 2012-12-05 17:19 It works quite well on Qt. ---------------------------------------------------------------------- Dibo · 2012-12-05 17:38 Hmm on my windows virtual box it is working too. It seems that this is GTK bug. I will report it. Thanks for testing