Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi 2009 - create a TPanel at runtime and change its color

got a strange problem: I create a TPanele at runtime and change its color - however, the color is still clBtnFace.

Here' the code:

procedure TForm1.Button1Click(Sender: TObject);
var
  pnlTest : TPanel;
begin
    pnlTest := TPanel.Create(Form1);
    pnlTest.Parent := Form1;
    pnlTest.Width := 100;
    pnlTest.Height := 100;
    pnlTest.Color := clRed;
end; 

Any ideas? Thanks!

like image 930
gonzales Avatar asked Sep 23 '10 12:09

gonzales


1 Answers

When you want to have colored panels under a themed OS you have to set ParentBackground to False.

like image 65
Uli Gerhardt Avatar answered Sep 29 '22 11:09

Uli Gerhardt