Delphi 2009 - 在运行时创建 TPanel 并更改其颜色
遇到一个奇怪的问题:我在运行时创建一个 TPaele 并更改其颜色 - 但是,颜色仍然是 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;
有什么想法吗?谢谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
当你想在主题操作系统下有彩色面板时,你必须将 ParentBackground 设置为 False。
When you want to have colored panels under a themed OS you have to set ParentBackground to False.
试试这个:-)
Try this :-)
这是 maXbox 脚本的代码:
This the code for maXbox scripting:
对于到达这里的 cpp builder 开发人员来说:
ParentBackground
、ParentColor
和FullRepaint
应设置为 falseFor those of you, cpp builder developers who arrive here:
ParentBackground
,ParentColor
andFullRepaint
should be set to false