TCalendar日历可以让某些日期自定义填充颜色吗?
就是软件的工作日志查看,在日历上想有有操作日志的日期标出来.
[解决办法]
刚才看了看,原来TCCalendar是继承自TCustomGrid,这样就好办了:
class TCrnCalendar: public TCCalendar
{
public:
void __fastcall DrawCell(int ACol, int ARow, const TRect &ARect,
TGridDrawState AState)
{
// 假设第4行第3列需要变色
if (ACol == 2 && ARow == 3)
{
Canvas->Brush->Color = clSkyBlue;
Canvas->Font->Color = clRed;
Canvas->Font->Style = Canvas->Font->Style << fsBold;
}
else
{
Canvas->Brush->Color = clWhite;
Canvas->Font->Color = clBlack;
Canvas->Font->Style = Canvas->Font->Style >> fsBold;
}
TCCalendar::DrawCell(ACol, ARow, ARect, AState);
}
__fastcall virtual TCrnCalendar(TComponent *AOwner): TCCalendar(AOwner)
{}
};
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TCrnCalendar *cc = new TCrnCalendar(this);
cc->Parent = this;
cc->Left = 100;
cc->Top = 100;
cc->Show();
}