Delphi 2009 - 在运行时创建 TPanel 并更改其颜色 [英] Delphi 2009 - create a TPanel at runtime and change its color

查看:28
本文介绍了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天全站免登陆