开发者

HardwareButton in Windows Mobile 6

I am attempting to utilize a hardware button on my Motorola MC75 to pe开发者_如何学编程rform the function of a button event that I created on the form. I have attempted to use the WindowsCE.Forms.HardwareButton class, however, I can't seem to get it working. I can't even capture any KeyDown event on the form. I set up the event and the KeyPreview is set to true on the form, however, the event is never fired on any hardware button I press on the device while debugging.

Any suggestions?

Thanks in advance.


There is a native function to forward all keys to your application.

[DllImport("coredll.dll", SetLastError = true)]
static extern bool AllKeys(bool bAllKeys);

See this MSDN blog for a C++ example. You can receive KeyDown and KeyUp events on a Windows Form using AllKeys. It works on any Windows Mobile 2003 - current device.


Hardware button control is usually device-specific. Motorola/Symbal have an SDK for their devices, but I wasn't able to find a link to it. Normally, there will be a manufacturer-specific DLL on the devices that you would PInvoke into in order to read and control the hardware buttons.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜