日期:2014-05-18 浏览次数:20934 次
[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("Processing the messages : " + m.Msg); return true; } return false; } } 你的程序开始时 public Form1() { InitializeComponent(); TestMessageFilter msfilter = new TestMessageFilter(); Application.AddMessageFilter(msfilter); }
------解决方案--------------------