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
[40262] Re:ListView에서 Row 단위로 폰트 색깔 바뀌게 하는 방법좀요 ㅠ
alex [] 1534 읽음    2005-05-23 13:22
이성제 님이 쓰신 글 :
: 버튼을 클릭 했을때
:
: 한 Row가 같은 색의 폰트로 모두 변하게 하는 방법이 필요 합니다 ㅠ

// use this as example..
// it won't change the color of column[0] and set the width as 0  
void __fastcall TMainForm::lvDetailsCustomDrawSubItem(
      TCustomListView *Sender, TListItem *Item, int SubItem,
      TCustomDrawState State, bool &DefaultDraw)
{
   TListItem* pItem = Sender->Selected ;
    bool bSelected = ( pItem && Item->Index == pItem->Index );

    RECT Rect = {LVIR_BOUNDS, SubItem, 0, 0};
    SNDMSG(Sender->Handle, LVM_GETSUBITEMRECT, Item->Index,reinterpret_cast<LPARAM>(&Rect));

  // make sure the current transaction is painted selected
    if (bSelected)
    {
        if (Item->SubItems->Strings[1] == "R")
            Sender->Canvas->Brush->Color = clMaroon;
        else if (Item->SubItems->Strings[1] == "H")
            Sender->Canvas->Brush->Color = clPurple;
        else
            Sender->Canvas->Brush->Color = clNavy;
    }
    else
        Sender->Canvas->Brush->Color = clWindow;
    Sender->Canvas->FillRect(Rect);

    // now change the color of the transaction based on the Statu
    if (bSelected)
        Sender->Canvas->Font->Color = clWhite;
    else if (Item->SubItems->Strings[1] == "R")
            Sender->Canvas->Font->Color = clMaroon;
    else if (Item->SubItems->Strings[1] == "H")
            Sender->Canvas->Font->Color = clPurple;
    else
       Sender->Canvas->Font->Color = clWindowText;

    HDC Hdc = Sender->Canvas->Handle;
    AnsiString text(Item->SubItems->Strings[SubItem-1]);
    SetBkMode(Hdc, TRANSPARENT);
    SetTextColor(Hdc, Sender->Canvas->Font->Color);

    Rect.right-=4;
    Rect.left+=4;
    DrawText(Hdc, text.c_str(), text.Length(),&Rect, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
    DefaultDraw = false;

}

+ -

관련 글 리스트
40253 ListView에서 Row 단위로 폰트 색깔 바뀌게 하는 방법좀요 ㅠ 이성제 821 2005/05/21
40262     Re:ListView에서 Row 단위로 폰트 색깔 바뀌게 하는 방법좀요 ㅠ alex 1534 2005/05/23
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.