Trapping Tab key... 
Author Message
 Trapping Tab key...

Hi all,
Does anyone know of a way to trap the Tab key from a text box (or any other
control for that matter). Microsoft seem to have stripped it out of the
KeyDown and KeyUp events for reasons best known to themselves. Basically I
need to know when the user has tabbed between two specific text boxes.
Thanks in advance.

Alex Tait
Force12 Solutions Ltd



Fri, 06 Oct 2000 03:00:00 GMT  
 Trapping Tab key...

Quote:

>Hi all,
>Does anyone know of a way to trap the Tab key from a text box (or any other
>control for that matter). Microsoft seem to have stripped it out of the
>KeyDown and KeyUp events for reasons best known to themselves. Basically I
>need to know when the user has tabbed between two specific text boxes.

If EVERY control on your form has TabStop=False, then you can trap the Tab
key in the KeyPress event ONLY. It still is not available in KeyDown or
KeyUp(!) This behavior bugs the hell out of me, but what can you do?

I take it from your post that you specifically want to know when the user
presses the Tab key to go from Text1 to Text2 as opposed to clicking on
Text2, right? If all you wanted to know was when the text box got the focus,
you could use the GotFocus event. Sorry if that's "Well, DUH!" material to
you.



Sat, 07 Oct 2000 03:00:00 GMT  
 Trapping Tab key...

If the taborders of the textboxes and possibly other control are in increasing
order then.....To trap tabs out of Text1 do this.   Also look that the
documenation for WM_KILLFOCUS message for a control.

Global TabCancel as Boolean

Form_Load()
    TabCancel = False
End sub

Text1_GotFocus()
    'No code here

    If Not TabCancel Then
            'Some code for getfocus event
    Endif
    TabCancel = False
     'No code here
End sub

Text1_LostFocus()  
   If Activecontrol.TabOrder > Text2.Taborder then
        'Forward tab detected
    Else
        'Reverse Tab (Shift+Tab) detected
    Endif

    'Set TabCancel to true to keep the focus in
    'TabCancel = False
    'TabCance = True

    If TabCancel then Text1.SetFoucs
End sub



Tue, 10 Oct 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Trapping TAB Key

2. Trapping TAB key?

3. Trapping Tab Key

4. How to trap TAB key? ---URGENT

5. Trapping Tab key - VB5.0

6. Trap TAB key for Validation

7. Trapping TAB key?

8. HELP! Trapping TAB key

9. Trapping Tab key

10. Trapping TAB key : problem and solution

11. Trap TAB KEY

12. Why does SS Tab trap key events before the form traps them

 

 
Powered by phpBB® Forum Software