I want to trap a key press for my application but the application does not
seem to trigger the KeyPress,KeyDown or KeyUp events. I have a menu and a
picture on the main dialog. Is this a focus issue? or do I need to add
further event handling?
--
Steve H.

Re: Trapping Key Presses. by Mehdi

Mehdi
Tue Mar 14 08:51:58 CST 2006

On Tue, 14 Mar 2006 06:22:27 -0800, Steve wrote:

> I want to trap a key press for my application but the application does not
> seem to trigger the KeyPress,KeyDown or KeyUp events. I have a menu and a
> picture on the main dialog. Is this a focus issue? or do I need to add
> further event handling?

A form's KeyPress, KeyDown and KeyUp events are fired only if the form
itself has the focus. If a child control within the form has the focus,
then this is this control's KeyPress, KeyDown and KeyUp events that are
going to be fired. You can force your form's events to be fired first even
if the focus is on one of its child control by setting its KeyPreview
property to true.