tags:

views:

112

answers:

2

hi,

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!

A: 

Uhm, just found out why:

I've had enabled the "runtime themes" on my project. When I disable it, it works!

But why?

gonzales
Exactly because the panel is themed. When you tell it to be not themed, it becomes colored.
Eugene Mayevski 'EldoS Corp
And how can I tell the panel that it is "not themed" (except disable the runtime themes in the project) ? thx!
gonzales
The whole point about themed is that for standard controls, the themed UI properties override your own.
Jeroen Pluimers
+4  A: 

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

Ulrich Gerhardt
I tried it, but it doesn't work.
gonzales
Ah sorry, it works! I set ParentColot to false, not ParentBackground. Thx!
gonzales