简体   繁体   English

如何在Windows Mobile 6上捕获硬件按键事件?

[英]How to catch hardware key press event on Windows Mobile 6?

I'm trying to catch hardware key press events on Windows Mobile 6.x with .NET 3.5 I have a form with buttons and other controls on it and I need to catch when keys left, right, up, and down are pressed. 我正在尝试在具有.NET 3.5的Windows Mobile 6.x上捕获硬件按键事件,我有一个带有按钮和其他控件的表单,我需要在按下左,右,上和下键时进行捕获。 Unfortunately, with approach described in MSDN: 不幸的是,使用MSDN中描述的方法:

http://msdn.microsoft.com/en-us/library/microsoft.windowsce.forms.hardwarekeys.aspx http://msdn.microsoft.com/zh-cn/library/microsoft.windowsce.forms.hardwarekeys.aspx

all these keys still move cursor between buttons on the form instead of triggering my Form1_KeyDown() event. 所有这些键仍然在窗体上的按钮之间移动光标,而不是触发我的Form1_KeyDown()事件。 (I have HardwareButtons with associated control Form1 and HardwareKey set up). (我有带有关联控件Form1和HardwareKey的HardwareButtons设置)。

Is there any way of catching these key press events in C#? 有没有办法在C#中捕获这些按键事件?

如果将窗体的KeyPreview属性设置为true,则可以捕获窗体的KeyDown事件。

我认为您必须在表单中放置6个HardwareButtons并将控件属性关联到表单,并且每个HardwareButton的HarwareKey属性应该相对地设置为ApplicationKey1到ApplicationKey6。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM