Board index » cppbuilder » flicker in ListView
Wifetaker
![]() CBuilder Developer |
flicker in ListView2006-03-06 11:34:48 AM cppbuilder97 Hi, I have a strange problem with flicker on my custom-drawn ListView. All is fine, except when I change the font color from item to item, I get flicker. Here's the code: void __fastcall TGamesForm::ListView1AdvancedCustomDrawItem( TCustomListView *Sender, TListItem *Item, TCustomDrawState State, TCustomDrawStage Stage, bool &DefaultDraw) { DefaultDraw = false; TListView *lv = (TListView *)(Sender); FICSGame *g = (FICSGame *)(Item->Data); TRect rect = Item->DisplayRect(drBounds); if (State.Contains(cdsSelected)) { TRect focus = rect; lv->Canvas->Brush->Color = clYellow; lv->Canvas->FrameRect(focus); InflateRect(&focus, -1, -1); lv->Canvas->Brush->Color = clNavy; lv->Canvas->FillRect(focus); lv->Font->Color = clWhite; } else { lv->Canvas->Brush->Color = clWhite; lv->Canvas->FillRect(rect); lv->Font->Color = clBlack; } if (g && g->Observed) ImageList1->Draw(lv->Canvas, 1, rect.Top, 1, true); if (g && g->Examined) ImageList1->Draw(lv->Canvas, 19, rect.Top, 0, true); TRect textrect(37, rect.top + 2, lv->Columns->Items[0]->Width - 4, rect.bottom); DrawText(lv->Canvas->Handle, Item->Caption.c_str(), Item->Caption.Length(), &textrect, DT_END_ELLIPSIS); textrect.Left = textrect.Right + 4; textrect.Right += lv->Columns->Items[1]->Width; DrawText(lv->Canvas->Handle, Item->SubItems->Strings[0].c_str(), Item->SubItems->Strings[0].Length(), &textrect, DT_END_ELLIPSIS); int last = Item->SubItems->Count; if (lv != ListView1) last--; for (int count = 1; count < last; count++) { textrect.Left = textrect.Right + 4; textrect.Right += lv->Columns->Items[count + 1]->Width; DrawText(lv->Canvas->Handle, Item->SubItems->Strings[count].c_str(), Item->SubItems->Strings[count].Length(), &textrect, DT_END_ELLIPSIS); } } OwnerDraw is set to false. The DoubleBuffered property of both the ListView and the form is set to true. Also, for both, ControlStyle << csOpaque. The only time it flickers is when an item is selected and the font color is changed from item to item (based on whether it's selected). What could be the cause? |