[英]C++ Builder RAD Studio XE7 change color of a Panel
按下按钮后,我想将面板的颜色更改为绿色:
ErrorDetectorPanel->Brush->Color = clLime;
不起作用。
ErrorDetectorPanel->Color = clLime;
ErrorDetectorPanel->Refresh();
不起作用。
上瘾:
ErrorDetectorPanel->ParentColor = false;
ErrorDetectorPanel->Refresh();
它仍然不起作用。
尝试过这种方式:
HBRUSH brush = CreateSolidBrush(RGB(0, 255, 0));
SetWindowLong(ErrorDetectorPanel->Handle,WM_ERASEBKGND, 0);
SetWindowLong(ErrorDetectorPanel->Handle,GCLP_HBRBACKGROUND, (LONG)brush);
按下按钮后,TForm透明度为假,结果相同。
我该怎么办?
设置TPanel.Color
属性是正确的解决方案(它将自动将ParentColor
设置为false),但是必须使用TPanel
(或整个程序)禁用主题设置/样式,才能使用自定义着色。 主题/样式控件从活动的主题/样式中获得颜色。
我用
TPanel *tp[]={Panel454,Panel455,Panel456};
for(int i=sizeof(tp)/sizeof(tp[0]);--i>=0;){
tp[i]->ParentBackground=false;
tp[i]->StyleElements = TStyleElements(); // disable all
// tp[i]->CleanupInstance();
tp[i]->Color=clSkyBlue;
}
如果使用了主题/样式控件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.