Delphi 2009 - 在运行时创建一个TPanel并改变它的颜色 [英] Delphi 2009 - create a TPanel at runtime and change its color

查看:237
本文介绍了Delphi 2009 - 在运行时创建一个TPanel并改变它的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个奇怪的问题:我在运行时创建了一个TPanele,并改变了它的颜色 - 然而,颜色仍然是clBtnFace。

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

这里是代码:

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; 

任何想法?谢谢!

推荐答案

当您想在主题操作系统下有彩色面板时,必须将ParentBackground设置为False。

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

这篇关于Delphi 2009 - 在运行时创建一个TPanel并改变它的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆