Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


No Events when pressing Arrow-Keys in VB

This topic is 5887 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have the following problem. I had a control programmed in c++ which is on a VB-Form. Now I want to react when some arrow-keys on the keyboard is pressed. But i get no events. I catch the Events WM_KEYDOWN and WM_KEYUP but when i press the arrow-keys it seems that this events where swallowed by VB or something else. So I cannot react in my control on arrow-Key presses. Does anyone know a solution for this problem. Maybe it has to do with the Tab-Order of the Controls which are on the VB-Form. Peter Gmeiner

Share this post

Link to post
Share on other sites
set KeyPreview to be true for the form...

now override the KeyDown procedure for the form and pass the arrow key presses to your control... i think the test you need to do is something like:

select case KeyCode
case vbKeyUp, vbKeyDown
''Invoke the handler(s) for the key presses in your control
Call yourControl.KeyPressRoutine(keycode)
case else
''Do sod all
Exit Sub
end select

hope that helps...

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!