【问题标题】:C++ Builder RAD Studio XE7 change color of a PanelC++ Builder RAD Studio XE7 改变面板的颜色
【发布时间】:2015-11-24 14:46:56
【问题描述】:

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

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 透明度为假 按下按钮后结果相同。

我怎样才能做到正确?

【问题讨论】:

    标签: c++ c++builder tpanel


    【解决方案1】:

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

    【讨论】:

    【解决方案2】:

    我用

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多