Arrow Keys, PageUp, PageDn etc. Not Firing KeyDown Event

P

Phil Galey

I have a Panel control docked on all sides on a form and the panel control
contains a PictureBox. I'm using the KeyDown event of the form to respond to
the [+] and [-] keys for resizing the image and the PageUp, PageDn, Home,
End, and arrow keys for scrolling the Panel control.

Resizing the image using the [+] and [-] keys works fine, deriving a resized
thumbnail from the image and reassigning it to the Image property of the
PictureBox. However I'm running into a problem where the scrolling keys are
placing the form into a state where it suddenly no longer responds to any
keys. KeyDown and KeyPress will no longer fire, unless I quit the program
and restart it.

Could there be something else that might be capturing the other keys and
altering the functionality of the form? I had placed two buttons on the form
and noticed that the arrow keys were toggling the focus between the two
buttons, rather than scrolling the Panel.

Question:
How can I get the "scrolling" keys to fire the KeyDown event and prevent the
form from getting into that apparently form-editing state?
 
C

Chris

Phil said:
I have a Panel control docked on all sides on a form and the panel control
contains a PictureBox. I'm using the KeyDown event of the form to respond to
the [+] and [-] keys for resizing the image and the PageUp, PageDn, Home,
End, and arrow keys for scrolling the Panel control.

Resizing the image using the [+] and [-] keys works fine, deriving a resized
thumbnail from the image and reassigning it to the Image property of the
PictureBox. However I'm running into a problem where the scrolling keys are
placing the form into a state where it suddenly no longer responds to any
keys. KeyDown and KeyPress will no longer fire, unless I quit the program
and restart it.

Could there be something else that might be capturing the other keys and
altering the functionality of the form? I had placed two buttons on the form
and noticed that the arrow keys were toggling the focus between the two
buttons, rather than scrolling the Panel.

Question:
How can I get the "scrolling" keys to fire the KeyDown event and prevent the
form from getting into that apparently form-editing state?

Capture the ProcessCmdKey event. It will give you access to those keys.

Chris
 
P

Phil Galey

Excellent. That does the trick. Thanks.


Chris said:
Phil said:
I have a Panel control docked on all sides on a form and the panel control
contains a PictureBox. I'm using the KeyDown event of the form to respond to
the [+] and [-] keys for resizing the image and the PageUp, PageDn, Home,
End, and arrow keys for scrolling the Panel control.

Resizing the image using the [+] and [-] keys works fine, deriving a resized
thumbnail from the image and reassigning it to the Image property of the
PictureBox. However I'm running into a problem where the scrolling keys are
placing the form into a state where it suddenly no longer responds to any
keys. KeyDown and KeyPress will no longer fire, unless I quit the program
and restart it.

Could there be something else that might be capturing the other keys and
altering the functionality of the form? I had placed two buttons on the form
and noticed that the arrow keys were toggling the focus between the two
buttons, rather than scrolling the Panel.

Question:
How can I get the "scrolling" keys to fire the KeyDown event and prevent the
form from getting into that apparently form-editing state?

Capture the ProcessCmdKey event. It will give you access to those keys.

Chris
 

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