C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[26858] Re:나 죽네..--; (특정셀의 배경색 바꾸기..)
smleelms [smleelms] 2544 읽음    2003-08-21 17:44
단편적인 코드라 도움이 되실지는 모르겠습니다만, 혹시나 하는 마음에 올려봅니다.
일일이 주석을 달아드리지 못하는점 양해바라구요, 구현된 화면도 첨부파일로 올려봅니다.
암만해도 눈에 보이면 더 편하겠지요..

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;
}

+ -

관련 글 리스트
26841 나 죽네..--; (특정셀의 배경색 바꾸기..) 요구르트 1260 2003/08/21
26858     Re:나 죽네..--; (특정셀의 배경색 바꾸기..) smleelms 2544 2003/08/21
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.