StatusBar如何设置背景色
之前用过StatusBar,设置背景色是挺容易的。好长时间没用BCB了,发现现在找不到方法来修改它的背景色。如何修改StatusBar中Panel的颜色?
[解决办法]
//---------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
StatusBar1->Panels->Items[0]->Style = psOwnerDraw;
}
//---------------------------------------
void __fastcall TForm1::StatusBar1DrawPanel(TStatusBar *StatusBar,
TStatusPanel *Panel, const TRect &Rect)
{
if(Panel->Index == 0)
{
StatusBar->Canvas->Brush->Color = clGreen;
StatusBar->Canvas->FillRect(Rect);
StatusBar->Canvas->TextOutA(Rect.Left + 2, Rect.Top + 1, Panel->Text);
}
}
//---------------------------------------