|
- public static void FilterMassage(IntPtr from)
- {
- NativeMethods.Message ms = new NativeMethods.Message();
- uint index = 0;
- while (true)
- {
- //while (NativeMethods.PeekMessage(out ms, this.Handle, 0, 0, 1)) ;
- bool ret = NativeMethods.PeekMessage(out ms, from, index, index, 1);
- if (!ret)
- {
- break;
- }
- else
- {
- if (ms.msg == 15)
- {
- index++;
- }
- }
- }
- }
- }
- public class NativeMethods
- {
- /**/
- /// Windows Message
- [StructLayout(LayoutKind.Sequential)]
- public struct Message
- {
- public IntPtr hWnd;
- public uint msg;
- public IntPtr wParam;
- public IntPtr lParam;
- public uint time;
- public System.Drawing.Point p;
- }
- [DllImport("coredll.dll", CharSet = CharSet.Auto)]
- public static extern bool PeekMessage(out Message msg, IntPtr hWnd, uint messageFilterMin, uint messageFilterMax, uint flags);
- [DllImport("coredll.dll", CharSet = CharSet.Auto)]
- public static extern bool GetMessage(out Message msg, IntPtr hWnd, uint messageFilterMin, uint messageFilterMax);
- }
复制代码
最后的方法是调用了windows API,将所有的操作完成之前的Enter从按键序列中删除 |
|