1 public partial class Form1 : Form,IMessageFilter 2 { 3 public Form1() 4 { 5 InitializeComponent(); 6 } 7 8 #region IMessageFilter 成员 9 10 public bool PreFilterMessage(ref Message m) 11 { 12 //鼠标移动:512 13 //鼠标滚轮:522 14 //鼠标左键: 15 //down :513 16 //up :514 17 //double click:515 18 //鼠标右键: 19 //down :516 20 //up :517 21 // 22 if (m.Msg == 522)//不响应鼠标滚轮消息 23 { 24 return true; 25 } 26 else 27 { 28 return false; 29 } 30 } 31 32 #endregion 33 34 35 private voi button1_Click(object sender,EventArgs e) 36 { 37 Application.AddMessageFilter(this); 38 MessageBox.show(“鼠标滚轮已经被禁止!”,信息提示”,MessageBoxButtons.OK,MessageBoxIcn.Information); 39 } 40 41 private voi button2_Click(object sender,EventArgs e) 42 { 43 Application.RemoveMessageFilter(this); 44 MessageBox.show(“鼠标滚轮禁止已取消!”,信息提示”,MessageBoxButtons.OK,MessageBoxIcn.Information); 45 } 46}