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
[40033] Re:[질문] StringGrid에서 셀의 색상 바꿀 때 Selected된 Cell..
황경록 [mpbox] 4124 읽음    2005-05-02 20:02
굳이 코맨트를 달자면  gdSelected 를 그리고 폰트색을 처리하지 않으셨기 때문에 발생한 현상 같습니다.

gdSelected 는 현재 선택된 단일 또는 다중셀의 색입니다 ^^

즐빌하세요 ^^*


    TStringGrid *pGrid = dynamic_cast<TStringGrid *>(Sender);
    AnsiString sData = pGrid->Cells[ACol][ARow];

    if( State.Contains(gdFixed))
    {
        // nothing to do..=> fixed row
    }
    else if( State.Contains(gdSelected) )
    {
        // Draw Canvas

        pGrid->Canvas->Brush->Color = clGray;
        pGrid->Canvas->Pen->Color = clWhite;
        pGrid->Canvas->Font->Color = clWhite;
    }
    else
    {
        if ( ACol <  6 )
        {
            pGrid->Canvas->Brush->Color = clWhite;
            pGrid->Canvas->Pen->Color = clBlack;
            pGrid->Canvas->Font->Color = clBlack;
        }
        else if ( ACol == 6 )
        {
            pGrid->Canvas->Brush->Color = clRed;
            pGrid->Canvas->Pen->Color = clWhite;
            pGrid->Canvas->Font->Color = clWhite;
        }
        else if ( ACol > 6 )
        {
            pGrid->Canvas->Brush->Color = clYellow;
            pGrid->Canvas->Pen->Color = clGray;
            pGrid->Canvas->Font->Color = clGray;
        }
    }

    pGrid->Canvas->FillRect(Rect);
   
    unsigned oldalign = SetTextAlign( pGrid->Canvas->Handle, TA_CENTER );
    pGrid->Canvas->TextRect( Rect, (Rect.Right+Rect.Left)/2, Rect.Top+3, sData );
    SetTextAlign(pGrid->Canvas->Handle, oldalign);


땅주인 님이 쓰신 글 :
: 안녕하세요..  StringGride의 특정 셀의 색상을 바꾸려고 하는데..
: 여기 게시판의 내용을 검색해서 만들기는 만들었는데..
: 유독, 현재 Focus가 가 있는 셀은 글자가 나오지 않습니다.
: 그러다가, 그리드의 아무 셀이나 마우스로 선택하면 내용이 표시됩니다.
: 아래의 코드를 보시고 어디가 잘못되었는 지  지적 바랍니다..
:
: 아래의 코드는 6번째 컬럼 이전의 컬럼은 무조건 흰색 바탕에 검은 색 글자,
: 6번째 컬럼은 컬럼의 상황에 따라 색상 지정,
: 6번째 이상 컬럼도 상황에 따라 색상을 지정하고, 글자 색은 모두 검정색입니다.
:
: Focus가 가 있는 Cell은 색상 지정만 되고 글자가 표시되지 않는데..
: 포커스가 다른 곳으로 도망가면 다시 글자는 나타나는데..어찌된 영문 인 지..
: 고수님들의 의견 바랍니다...
:
: 감사합니다.
:
: void __fastcall TTestForm::StringGrid_TestDrawCell(TObject *Sender,
:       int ACol, int ARow, TRect &Rect, TGridDrawState State)
: {
:     TStringGrid *pGrid = dynamic_cast<TStringGrid *>(Sender);
:     AnsiString sData = pGrid->Cells[ACol][ARow];
:
: #ifdef _DEBUG
:     AnsiString aa= "Cell[" + IntToStr(ACol) + "][" + IntToStr(ARow) + "]";
:     if ( State.Contains(gdFixed    ))        aa += "State = gdFixed";
:     else if ( State.Contains(gdSelected)) aa += "State = gdSelected";
:     else if ( State.Contains(gdFocused))  aa += "State = gdFocused";
:     else aa += "None";
:     aa += "[DATA] = " + sData;
:     OutputDebugString(aa.c_str());
: #endif
:
:     if ( State.Contains(gdFixed)) {
:         // nothing to do..=> fixed row
:     } else {
:         if ( ACol <  6 ) {
:             pGrid->Canvas->Brush->Color = clWhite;
:             pGrid->Canvas->FillRect(Rect);
:         } else if ( ACol == 6 ) {
:             int iDecision ;
:             iDecision = xGetDecisionFromStr(sData);
:             switch ( iDecision ) {
:                 case EXAM_BEFORE:
:                     pGrid->Canvas->Brush->Color = (TColor)m_iSetup_ColorBefore;
:                     break;
:                 case EXAM_PASSED:
:                     pGrid->Canvas->Brush->Color = (TColor)m_iSetup_ColorPass;
:                     break;
:                 case EXAM_NOTPASSWD:
:                     pGrid->Canvas->Brush->Color = (TColor)m_iSetup_ColorNotPass;
:                     break;
:                 case EXAM_FAIL:
:                     pGrid->Canvas->Brush->Color = (TColor) m_iSetup_ColorFail;
:                     break;
:                 case EXAM_FORCEFAIL:
:                     pGrid->Canvas->Brush->Color = (TColor)m_iSetup_ColorForceFail;
:                     break;
:                 case EXAM_WRONGTEST:
:                     pGrid->Canvas->Brush->Color = (TColor)m_iSetup_ColorWrongTest;
:                     break;
:                 case EXAM_NOTATTEND:
:                     pGrid->Canvas->Brush->Color = (TColor)m_iSetup_ColorAbsent;
:                     break;
:                 case EXAM_ETC:
:                     pGrid->Canvas->Brush->Color = (TColor)m_iSetup_ColorBefore;
:                     break;
:                 case EXAM_TEST:
:                     pGrid->Canvas->Brush->Color = (TColor)m_iSetup_ColorTesting;
:                     break;
:                 default :
:                     break;
:             }
:             pGrid->Canvas->FillRect(Rect);
:         } else if ( ACol > 6 ) {
:             if ( sData == ""  ) {
:                 pGrid->Canvas->Brush->Color = clWhite;
:             } else if ( StrToInt(sData) < 0 ) {
:                 pGrid->Canvas->Brush->Color = clRed;
:             } else {
:                 pGrid->Canvas->Brush->Color = clLime;
:             }
:             pGrid->Canvas->FillRect(Rect);
:         } else {
:             pGrid->Canvas->Brush->Color = clWhite;
:             pGrid->Canvas->FillRect(Rect);
:         }
:     }
:
:     // Cell Text Print
:     unsigned oldalign = SetTextAlign(pGrid->Canvas->Handle, TA_CENTER);
:     pGrid->Canvas->TextRect(Rect, (Rect.Right+Rect.Left)/2, Rect.Top+3, sData);
:     SetTextAlign(pGrid->Canvas->Handle, oldalign);
: }

+ -

관련 글 리스트
40031 [질문] StringGrid에서 셀의 색상 바꿀 때 Selected된 Cell.. 땅주인 1301 2005/05/02
40033     Re:[질문] StringGrid에서 셀의 색상 바꿀 때 Selected된 Cell.. 황경록 4124 2005/05/02
40043         땡큐...땡큐..땡큐~~~~~~~!!!(내용무) 땅주인 858 2005/05/03
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.