|
단편적인 코드라 도움이 되실지는 모르겠습니다만, 혹시나 하는 마음에 올려봅니다.
일일이 주석을 달아드리지 못하는점 양해바라구요, 구현된 화면도 첨부파일로 올려봅니다.
암만해도 눈에 보이면 더 편하겠지요..
void __fastcall TFormMain::StringGrid1DrawCell(TObject *Sender, int ACol,
int ARow, TRect &Rect, TGridDrawState State)
{
StringGrid1->Canvas->Font->Name = "Microsoft Sans Serif";
StringGrid1->Canvas->Font->Size = 11;
StringGrid1->Canvas->Font->Color = clBlack;
// fixed rows/cols cells
if(State.Contains(gdFixed))
{
StringGrid1->Canvas->Brush->Color = clYellow;
StringGrid1->Canvas->Font->Color = clWindowText;
StringGrid1->Canvas->FillRect(Rect);
Frame3D(StringGrid1->Canvas, Rect, clBtnHighlight, clBtnShadow, 1);
}
else // normal cells
{
if(ACol > CylNum && ACol < 13){ // 사용하지 않는 란
StringGrid1->Canvas->Brush->Color = clSilver;
// StringGrid1->Cells[ACol][ARow] = "";
}
else if(ACol <= CylNum && ARow > 2)// 계산 출력란
StringGrid1->Canvas->Brush->Color = clActiveBorder;
else
StringGrid1->Canvas->Brush->Color = clWindow;
StringGrid1->Canvas->Font->Color = StringGrid1->Font->Color;
StringGrid1->Canvas->FillRect(Rect);
}
// 센서로 관찰중인 실린더
if(SensorTag >= 7 && ACol == pEdtAry[SensorTag]->Text.ToInt() && ARow != 0){
StringGrid1->Canvas->Brush->Color = clLime;
StringGrid1->Canvas->FillRect(Rect);
}
if(State.Contains(gdFocused) && ACol <= CylNum && ARow > 0 && ARow < 3){
StringGrid1->Canvas->Brush->Color = clGradientActiveCaption;
StringGrid1->Canvas->FillRect(Rect);
GridX = StringGrid1->Col;
GridY = StringGrid1->Row;
}
if(ACol > 0 && ARow == 4) // 특정라인만 파란색 폰트로.
StringGrid1->Canvas->Font->Color = clBlue;
else if(ARow > 0 && ACol == 13){
StringGrid1->Canvas->Font->Color = clRed;
StringGrid1->Canvas->Font->Style = TFontStyles()<<fsBold;
}
else
StringGrid1->Canvas->Font->Color = clWindowText;
// text center align
if(ACol == 0 || ARow == 0 || ACol == 13){
unsigned oldalign = SetTextAlign(StringGrid1->Canvas->Handle, TA_CENTER);
StringGrid1->Canvas->TextRect(Rect, (Rect.Right+Rect.Left)/2, Rect.Top+1,
StringGrid1->Cells[ACol][ARow]);
SetTextAlign(StringGrid1->Canvas->Handle, oldalign);
}
else{ // text right align
unsigned oldalign = SetTextAlign(StringGrid1->Canvas->Handle, TA_RIGHT);
StringGrid1->Canvas->TextRect(Rect, Rect.Right-3, Rect.Top+2,
StringGrid1->Cells[ACol][ARow]);
SetTextAlign(StringGrid1->Canvas->Handle, oldalign);
}
StringGrid1->Canvas->Font->Style = TFontStyles()>>fsBold;
}
|