[英]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.