13,825
社区成员
发帖
与我相关
我的任务
分享
private: // User declarations
bool m_bFlags[25][8];
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
StringGrid1->Font->Name = "宋体";
StringGrid1->Font->Size = 9;
StringGrid1->Options = StringGrid1->Options >> goRowSizing >> goColSizing
>> goRowMoving >> goColMoving >> goEditing;
StringGrid1->Width = 560;
StringGrid1->Height = 175;
StringGrid1->RowCount = 8;
StringGrid1->ColCount = 25;
StringGrid1->DefaultColWidth = 20;
StringGrid1->DefaultRowHeight = 20;
StringGrid1->ColWidths[0] = 45;
LPTSTR lpWeeks[] =
{
"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"
};
for (int i = 0; i < 7; i++)
StringGrid1->Cells[0][i + 1] = lpWeeks[i];
for (int i = 0; i < 24; i++)
StringGrid1->Cells[i + 1][0] = String().sprintf(TEXT("%02d"), i);
memset(m_bFlags, 0x0, sizeof(m_bFlags));
}
// ---------------------------------------------------------------------------
void __fastcall TForm1::StringGrid1DrawCell(TObject *Sender, int ACol,
int ARow, TRect &Rect, TGridDrawState State)
{
if (ACol == 0 || ARow == 0) return;
if (State.Contains(gdSelected))
m_bFlags[ACol][ARow] = !m_bFlags[ACol][ARow];
if (m_bFlags[ACol][ARow])
StringGrid1->Canvas->Brush->Color = clRed;
else
StringGrid1->Canvas->Brush->Color = clWhite;
StringGrid1->Canvas->FillRect(Rect);
}