Avatar of shifty12
shifty12

asked on 

How can I trap the arrow keys on a VB6 form?

The form has keypreview=true and I have breakpoints set in keypress, keyup, and keydown. The breakpoints get a hit on almost all keys except the 4 arrow keys. What's so magic about them? Its tough to code a scroller routine w/o the arrow keys.
Visual Basic Classic

Avatar of undefined
Last Comment
shifty12
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of shifty12
shifty12

ASKER

Yes, numlock is on, but I'm not using the numpad arrows. I tried your code and keydown never gets control. Plz re-read my original comment. Thanx
Avatar of shifty12
shifty12

ASKER

Plz disregard my last comment. I turned numlock off and the keypad downarrow got a hit. So why doesn't the real downarrow key get a hit? Thanx
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

it is working on my computer. I can't say for yours! Maybe Scroll Lock?
SOLUTION
Avatar of JohnBPrice
JohnBPrice

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of shifty12
shifty12

ASKER

The prog is an icon viewer. I put 32 icons on the scrn in an Image array. I then simply scroll the images up and down. The only control that can accept a kb hit, other than form keypreview, are the Images which if clicked on simply draw a border around the icon. As stated earlier, for debugging I put a dummy statement like A=A at the top of keypress, keyup, and keydown and set a breakpoint on all 3. The 4 arrow keys never cause a break, nobody home. Also, if I do a SendKeys "{numlock}" the Microsoft wireless kb receiver light winks off then on and stays on. I only mention this cuz I thought I'd try the numpad arrows since the normal arrows don't work but numlock won't stay off.
SOLUTION
Avatar of jaynee
jaynee
Flag of Australia image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of shifty12
shifty12

ASKER

The 4 arrow keys cause my 2 buttons to alternately get focus, even with tabstop=false. So I physically removed the 2 buttons from the form, and guess what, the arrow keys get trapped. Why are the arrow keys acting like TAB when buttons are present?
Visual Basic Classic
Visual Basic Classic

Visual Basic is Microsoft’s event-driven programming language and integrated development environment (IDE) for its Component Object Model (COM) programming model. It is relatively easy to learn and use because of its graphical development features and BASIC heritage. It has been replaced with VB.NET, and is very similar to VBA (Visual Basic for Applications), the programming language for the Microsoft Office product line.

165K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo