Have you ever tried to control the hardware buttons on your PPC? Seen the Input example in the article on MSDN and still have no idea what's going on? Well then, here I come to the rescue.
Quite why MS can not make their examples simple enough for anyone to use I have no idea. I Googled for a simple example, but even after looking at every single link, I found no such thing, and so decided that maybe I should write about it. I did see a few cryptic responses in the newsgroups which pointed in the right direction, but actual examples are so much easier to digest.
I was going to put this article up on my site, but decided that CodeProject gets so many more users that it would be more beneficial here. The code is so simple that I don't believe it is necessary for me to convert it to C#, but if I do, then I will probably find a home for it on my site.
Using the Code
Well, it couldn't be any easier to use. Firstly, you'll need to add a reference to
Microsoft.WindowsCE.Forms. Next, create an instance of the class:
Private WithEvents KeyMessages As New HardwareKeyMessageWindow()
Then respond to the
Private Sub KeyMessages_HardwareKeyPressed(ByVal sender As Object, _
ByVal ke As HardwareKeyPressEventArgs) _
Select Case ke.KeyID
Points of Interest
Just to make the sample complete, I built a simple Etch-A-Sketch application. It's just a pity that there's no method to detect shaking :)
This is written in VS2003, but I expect it should work in VS2002.
I have tested the app on a Pocket PC running Windows for PocketPC 2002 (free gift of Viewsonic V37 from those nice people at MS) and Windows for PocketPC 2003 (NavMan PIN 570).