best way to trap keyboard input

D

droll

i've done this via a form but what if i want some global keyboard input
trapping? e.g. irregardless of which form i am in, i want my app to do
something when the user presses on 'A'. what is the best mechanism for doing
this? is there a place where i can define a global keyboard handler trap so
that i don't have to implement KeyPress event handlers in all my forms?
 
P

Paul G. Tobey [eMVP]

Well, there are two ways that jump to mind: hot keys and keyboard hooks.
Neither is a great idea for something like 'A', so you'd have to justify
this strange behavior of your application. If you just want to catch all
keys destined for your application, not those targeted at other windows, you
can use the OpenNETCF ApplicationEx class and an IMessageFilter to see the
keys before they are dispatched to, say, edit controls on your forms.

Paul T.
 
D

droll

the 'A' key was only an example. :) what i was looking for is a hotkey.
something that when pressed would activate my application. i've seen such an
app in the control panel of my wm5 device where you can assign various
hardware keys to launch apps. i guess i should just stick to that (assuming
it is an app that exists on most PPC devices).
 
P

Paul G. Tobey [eMVP]

RegisterHotKey() does that. The device may have a registry setting that
will allow you to associate an application with a hot key, too, but I'm not
up on, for example, Pocket PC registry settings. Alternatively, of course
PPC device have the type of application you describe for assigning an
application to a hard key.

Paul T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top