ListBox自画(100分)

  • 主题发起人 主题发起人 yjkarmon
  • 开始时间 开始时间
Y

yjkarmon

Unregistered / Unconfirmed
GUEST, unregistred user!
我在ListBox里的item画一个图标时,第一行是画有图标但是其他行都没有画出图标
请帮忙找出原因,是我的代码有问题吗,在哪?
代码:
...
void __fastcall Tforml::ListBox1DrawItem(TWinControl *Control,
int Index, TRect &Rect, TOwnerDrawState State)
{
ListBox1->Canvas->FillRect(Rect);
ImageList1->Draw(ListBox1->Canvas, Rect.Left+margin, Rect.Top+margin, 0 , true);
int ioff = (Rect.Bottom - Rect.Top - ImageList1->Height)/2;
ImageList1->Draw(ListBox1->Canvas, Rect.Left+margin, ioff, 0 , true);
AnsiString text = lbAttachment->Items->Strings[Index];
int off = (Rect.Bottom - Rect.Top-ListBox1->Canvas->TextHeight(text))/2;
ListBox1->Canvas->TextOut(Rect.Left+ilListBox->Width+2*margin, Rect.Top+off,ListBox1->Items->Strings[Index]);
}
 
后退
顶部