ActiveX - Tab Not Detected [*** RESOLVED ***]
I have an active X control with multiple picture boxes in it. I currently have it set up so that I can detect the keydown event for anything but the tab key. I don't care about the control losing focus as long as I can detect that the tab key was pressed, however I have not been able to do this...
Help!!!
Re: ActiveX - Tab Not Detected
I have tried everything I can think of including subclassing the control (as well as each of the subcontrols) to listen for the tab key with no success.
The only way I have found to do it is with the following code snippets:
http://www.vbaccelerator.com/home/VB/Code/Techniques/Trapping_The_Tab_Key_in_a_UserControl_with_IOLEInPlaceActiveObject/article.asp
Re: ActiveX - Tab Not Detected
If you end up using the code in the above link make sure you replace the ShiftState property with this one to ensure that you do not get overflow erros.
Code:
Private Property Get ShiftState() As Integer
Dim s, c As Long
s = GetAsyncKeyState(vbKeyShift)
c = GetAsyncKeyState(vbKeyControl)
If s And vbShiftMask > 0 And c And vbCtrlMask > 0 Then
ShiftState = 3
ElseIf s And vbShiftMask > 0 Then
ShiftState = 1
ElseIf c And vbCtrlMask > 0 Then
ShiftState = 2
Else
ShiftState = 0
End If
End Property