Capture all Key Press events

  • Thread starter Thread starter Chris Auld
  • Start date Start date
C

Chris Auld

Does anyone know of an elegant approach to capture all keypress events
on a form no matter what control is active?
Basically I have a PPC with hardware key pad and I always want the
KeyPress to affect a certain control.

Cheers
Chris
 
There is no "event passing" as there is in Delphi (correct me if I am
wrong), where an event would be passed from an active control to the
underlying form (or other parent container) if the control didn't have that
specific event. As far as I know, you need to add the event to all focusable
controls if you want to make sure it fires no matter what control is
focused.

Another problem with the current version of compact framework is that many
controls don't even support key press events (such as the combobox), which
has caused a lot of trouble for developers who are using managed code and
not as familiar with low level hooking etc. Luckily, Service Pack 2 for the
compact framework will add key press support to most controls.

Hope that answers your question.

/ Peter
 
Back
Top