Unit1.h:
void __fastcall CrnDrawListViewItem(TCustomListView *Sender,
TListItem *Item, TRect &Rect, TOwnerDrawState State)
{
//老妖的文章里是定义在TForm1的private里的
//void __fastcall TForm1::CrnDrawListViewItem(TCustomListView *Sender,TListItem *Item, TRect &Rect, TOwnerDrawState State)
}
Unit1.cpp
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
ListView1->OwnerDraw = true;
ListView1->RowSelect = true;
ListView1->ReadOnly = true;
ListView1->OnDrawItem =(TLVDrawItemEvent)&CrnDrawListViewItem;
}
报错内容为:
[BCC32 Error] Unit1.cpp(18): E2031 Cannot cast from 'void (_fastcall *)(TCustomListView *,TListItem *,TRect &,TOwnerDrawState)' to 'TLVDrawItemEvent'
Full parser context
Unit1.cpp(13): parsing: _fastcall TForm1::TForm1(TComponent *)