4355|6

68

帖子

0

TA的资源

一粒金砂(初级)

楼主
 

wince 清空键盘缓冲区 [复制链接]

如题.
如何清空wince系统的键盘缓冲区.
我想要的结果是,在一个操作进行的时候,如果操作员按下了别的按键,等这个操作进行完成以后,将用户按下的那些键清除,不作响应.

最新回复

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从按键序列中删除  详情 回复 发表于 2009-10-6 17:01
点赞 关注

回复
举报

77

帖子

0

TA的资源

一粒金砂(初级)

沙发
 
帮顶
 
 

回复

55

帖子

0

TA的资源

一粒金砂(初级)

板凳
 
up
 
 
 

回复

62

帖子

0

TA的资源

一粒金砂(初级)

4
 
没有什么好办法

可以考虑在操作过程中,将屏幕disable掉
 
 
 

回复

84

帖子

0

TA的资源

一粒金砂(初级)

5
 
不作响应,enablewindiow()--->false
 
 
 

回复

76

帖子

0

TA的资源

一粒金砂(初级)

6
 
HotKey 钩子
 
 
 

回复

70

帖子

0

TA的资源

一粒金砂(初级)

7
 

  1. public static void FilterMassage(IntPtr from)
  2.         {
  3.             NativeMethods.Message ms = new NativeMethods.Message();
  4.             uint index = 0;
  5.             while (true)
  6.             {
  7.                 //while (NativeMethods.PeekMessage(out ms, this.Handle, 0, 0, 1)) ;
  8.                 bool ret = NativeMethods.PeekMessage(out ms, from, index, index, 1);
  9.                 if (!ret)
  10.                 {
  11.                     break;
  12.                 }
  13.                 else
  14.                 {
  15.                     if (ms.msg == 15)
  16.                     {
  17.                         index++;
  18.                     }
  19.                 }
  20.             }
  21.         }
  22.     }

  23.       public class NativeMethods
  24.         {
  25.             /**/
  26.             /// Windows Message
  27.             [StructLayout(LayoutKind.Sequential)]
  28.             public struct Message
  29.             {
  30.                 public IntPtr hWnd;
  31.                 public uint msg;
  32.                 public IntPtr wParam;
  33.                 public IntPtr lParam;               
  34.                 public uint time;
  35.                 public System.Drawing.Point p;
  36.             }

  37.             [DllImport("coredll.dll", CharSet = CharSet.Auto)]
  38.             public static extern bool PeekMessage(out Message msg, IntPtr hWnd, uint messageFilterMin, uint messageFilterMax, uint flags);
  39.             [DllImport("coredll.dll", CharSet = CharSet.Auto)]
  40.             public static extern bool GetMessage(out Message msg, IntPtr hWnd, uint messageFilterMin, uint messageFilterMax);
  41.       }
复制代码


最后的方法是调用了windows API,将所有的操作完成之前的Enter从按键序列中删除
 
 
 

回复
您需要登录后才可以回帖 登录 | 注册

随便看看
查找数据手册?

EEWorld Datasheet 技术支持

相关文章 更多>>
关闭
站长推荐上一条 1/10 下一条
【回帖赢京东卡】说说无线技术那些事儿
即日起—2月28日,参与回帖讨论都有机会赢取【30元京东卡】

查看 »

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

 
机器人开发圈

About Us 关于我们 客户服务 联系方式 器件索引 网站地图 最新更新 手机版

站点相关: 国产芯 安防电子 汽车电子 手机便携 工业控制 家用电子 医疗电子 测试测量 网络通信 物联网

北京市海淀区中关村大街18号B座15层1530室 电话:(010)82350740 邮编:100190

电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved
快速回复 返回顶部 返回列表