c++c++buildertpanel

C++ Builder RAD Studio XE7 change color of a Panel


After pushing a button I wanted to change the color of a panel to green:

ErrorDetectorPanel->Brush->Color = clLime;

doesn´t work.

ErrorDetectorPanel->Color = clLime;
ErrorDetectorPanel->Refresh();

doesn´t work.

with this addiction:

ErrorDetectorPanel->ParentColor = false;
ErrorDetectorPanel->Refresh();

it still doesn´t work.

tried it this way:

HBRUSH brush = CreateSolidBrush(RGB(0, 255, 0));
SetWindowLong(ErrorDetectorPanel->Handle,WM_ERASEBKGND, 0);
SetWindowLong(ErrorDetectorPanel->Handle,GCLP_HBRBACKGROUND, (LONG)brush);

TForm transparency is false same result after pushing the button.

How can I do it right?


Solution

  • I use

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

    if the Themed/Styled controls used.