forked from Timelessww/DotNetARX2012
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMessageFilter.cs
More file actions
36 lines (34 loc) · 1.04 KB
/
Copy pathMessageFilter.cs
File metadata and controls
36 lines (34 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System.Windows.Forms;
namespace DotNetARX
{
/// <summary>
/// Windows消息过滤类
/// </summary>
public class MessageFilter : IMessageFilter
{
/// <summary>
/// 按键消息
/// </summary>
public const int WM_KEYDOWN = 0x0100;
/// <summary>
/// 按下的键名
/// </summary>
public Keys KeyName { get; set; }
/// <summary>
/// 在调度消息之前将其筛选出来
/// </summary>
/// <param name="m">消息名</param>
/// <returns>如果调试的是按键消息,则返回true,否则返回false</returns>
public bool PreFilterMessage(ref Message m)
{
if (m.Msg == WM_KEYDOWN)//如果调度的消息是按键
{
//设置键名
KeyName = (Keys)(int)m.WParam & Keys.KeyCode;
//返回true表示调度的是按键消息
return true;
}
return false;//返回false,表示非按键消息
}
}
}