|
이성제 님이 쓰신 글 :
: 버튼을 클릭 했을때
:
: 한 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;
}
|