自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

淺析如何屏蔽C#鼠標(biāo)滾輪相關(guān)事件

開發(fā) 后端
這里將介紹如何屏蔽C#鼠標(biāo)滾輪相關(guān)事件,本代碼示例主要解決滾動鼠標(biāo)滾動就改變值的問題。希望本文能對大家有所幫助。
C#鼠標(biāo)滾輪主要是針對鼠標(biāo)上的滾輪滾動中,改變值的問題。通過這一代碼能解決這個問題,其中需要用到IMessageFilter 成員。C#鼠標(biāo)滾輪也是鼠標(biāo)控制的重要組成部分。
  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. if (m.Msg == 522)   
  13. {   
  14. return true;   
  15. }   
  16. else   
  17. {   
  18. return false;   
  19. }   
  20.  
  21.  
  22. #endregion   
  23.  
  24. private void Form1_Load(object sender, EventArgs e)   
  25. {   
  26. Application.AddMessageFilter(this );   
  27. }   
  28. }   
  29. public partial class Form1 : Form,IMessageFilter  
  30. {  
  31. public Form1()  
  32. {  
  33. InitializeComponent();  
  34. }  
  35.  
  36. #region IMessageFilter 成員  
  37.  
  38. public bool PreFilterMessage(ref Message m)  
  39. {  
  40. if (m.Msg == 522)  
  41. {  
  42. return true;  
  43. }  
  44. else 
  45. {  
  46. return false;  
  47. }  
  48. }  
  49.  
  50. #endregion  
  51.  
  52. private void Form1_Load(object sender, EventArgs e)  
  53. {  
  54. Application.AddMessageFilter(this );  
  55. }  

這樣就可以實現(xiàn)當(dāng)一個控件,比如commbox或者numupdown等獲得焦點的時候,滾動鼠標(biāo)滾動就不會改變值了。

如何屏蔽C#鼠標(biāo)滾輪相關(guān)事件就介紹到這里。

【編輯推薦】

  1. C#關(guān)機(jī)代碼的實現(xiàn)淺析
  2. C#程序設(shè)計關(guān)閉Windows窗體淺析
  3. C#程序設(shè)計獲取系統(tǒng)信息的Windows窗體淺析
  4. C#遞歸算法理解的實例分析
  5. C#遞歸思路的使用實例詳解
責(zé)任編輯:彭凡 來源: e800技術(shù)客
相關(guān)推薦

2009-09-03 18:19:35

C#鼠標(biāo)右鍵

2009-08-12 15:20:21

C#事件處理

2009-09-10 12:00:09

C# listbox

2009-08-28 16:03:15

C#程序?qū)崿F(xiàn)鼠標(biāo)移動

2009-09-07 04:19:56

C#窗體事件

2009-08-31 09:20:37

C#事件注冊和注銷

2009-09-09 11:29:32

C# TextBox事

2009-09-15 15:40:25

C# 綁定

2009-10-09 09:07:40

C#委托和事件

2009-09-02 18:34:28

C#鼠標(biāo)事件

2009-08-19 16:42:41

C#如何使用XML

2009-08-31 18:34:57

C#接口事件

2009-09-07 05:31:39

C#窗體關(guān)閉事件

2009-08-20 17:47:54

C#異步編程模式

2009-09-11 09:20:00

C# button事件

2009-09-02 18:28:00

C#鼠標(biāo)位置

2009-09-07 18:41:18

2009-12-30 10:44:38

Silverlight

2009-08-14 17:45:52

C# ArrayLis

2009-08-17 18:34:50

C# ChangeCo
點贊
收藏

51CTO技術(shù)棧公眾號