13,825
社区成员
发帖
与我相关
我的任务
分享
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)
}
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
ListView1->OwnerDraw = true;
ListView1->RowSelect = true;
ListView1->ReadOnly = true;
ListView1->OnDrawItem =(TLVDrawItemEvent)&CrnDrawListViewItem;
}
---h文件
#ifndef Unit2H
#define Unit2H
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Dialogs.hpp>
//---------------------------------------------------------------------------
struct TMyevent
{
public:
int a;
void __fastcall Button1Click(TObject *Sender);
};
struct TMyevent myevent;
#endif
----cpp文件
#pragma hdrstop
#include "Unit2.h"
#pragma package(smart_init)
void __fastcall TMyevent::Button1Click(TObject *Sender)
{
ShowMessage("hellO");
}
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include "Unit2.h"
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
void __fastcall TForm1::FormCreate(TObject *Sender)
{
Button1->OnClick = myevent.Button1Click;
}