zoukankan      html  css  js  c++  java
  • C#通过IMessageFilter捕获鼠标消息

     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}

    本文来自博客园,作者:ganjiqi,转载请注明原文链接:https://www.cnblogs.com/ganjiqi/p/14980103.html

  • 相关阅读:
    杂项
    hdu 2094
    hdu acm 1004
    android 重装sdk或者系统的时模拟器出现can open ****
    使用Java模拟操作系统高优先级算法
    各种语法解释及用法
    枚举与结构
    闭包
    socket
    异常
  • 原文地址:https://www.cnblogs.com/ganjiqi/p/14980103.html
Copyright © 2011-2022 走看看