Trapping Key Presses.

G

Guest

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?
 
M

Mehdi

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.
 

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