0

按下按钮后,我想将面板的颜色更改为绿色:

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 透明度是错误的相同结果。

我怎样才能做到正确?

4

2 回答 2

3

设置TPanel.Color属性是正确的解决方案(它将自动设置ParentColor为 false),但是您必须禁用TPanel(或整个程序)上的主题/样式设置才能使用自定义着色。主题/样式控件从活动主题/样式中获取颜色。

于 2015-11-25T02:59:20.563 回答
1

我用

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;
        }

如果使用了主题/样式控件。

于 2019-07-31T09:40:45.877 回答