例子代码:
class MyListView : ListView
{
public event EventHandler HScroll;
public event EventHandler VScroll;
class MyListView : ListView
{
public event EventHandler HScroll;
public event EventHandler VScroll;
MyListView()
{
this.HScroll += new EventHandler(OnHScroll);
this.VScroll += new EventHandler(OnVScroll);
}
const int WM_HSCROLL = 0x0114;
const int WM_VSCROLL = 0x0115;
protected override void WndProc(ref Message m)
{
if(m.Msg == WM_HSCROLL)
{
OnHScroll(this, new EventArgs());
}
else if(m.Msg == WM_VSCROLL)
{
OnVScroll(this, new EventArgs());
}
base.WndProc (ref m);
}
virtual protected void OnHScroll(object sender, EventArgs e)
{
}
virtual protected void OnVScroll(object sender, EventArgs e)
{
}
}