日期:2014-05-18 浏览次数:20936 次
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)] public class TestMessageFilter : IMessageFilter { public bool PreFilterMessage(ref Message m) { if (m.Msg >= 513 && m.Msg <= 515) { Console.WriteLine("点击了 : " + m.Msg); } return false; } } 主窗体初始化时 public Form1() { InitializeComponent(); TestMessageFilter filter = new TestMessageFilter(); Application.AddMessageFilter(filter); }