I don't understand why this is needed but it fixes the problem.
VB Code:
Select Case KeyCode Case vbKeyF9 tabTest.Tab = 0 DoEvents Case vbKeyF10 tabTest.Tab = 1 DoEvents Case vbKeyF11 tabTest.Tab = 2 DoEvents End Select [b]KeyCode = 0[/b]
Printable View
I don't understand why this is needed but it fixes the problem.
VB Code:
Select Case KeyCode Case vbKeyF9 tabTest.Tab = 0 DoEvents Case vbKeyF10 tabTest.Tab = 1 DoEvents Case vbKeyF11 tabTest.Tab = 2 DoEvents End Select [b]KeyCode = 0[/b]
We also seem to have a forum bug. Note that my first post is out of order.
When using the sstab, I setup function keys to move between the tabs on the keydown event. This works for the most part, but sometimes not.
Example:
I have 3 tabs (F9,F10,F11). If I hit F10, it acts like it hangs... not responding to further presses of F11 or F9. However, if I go to F11, I can easily bounce between F9 and F11 and the tabs respond accordingly.
Also, I have another sstab with 5 and I've setup F1 and F2 to cycle through the tabs... for some reason it doesn't want to jump correctly.
Here is the code:VB Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) On Error GoTo Form_KeyDown_Error If KeyCode = vbKeyF3 Then If tabOptions.Visible = False Then cmdStop_Click End If End If If KeyCode = vbKeyF4 Then If tabOptions.Visible = True Then cmdStart_Click End If End If If tabOptions.Visible = True Then Select Case KeyCode Case 13 If tabOptions.Tab = 2 Then cmdAdd_Click End If If tabOptions.Tab = 5 Then cmdAddLimit_Click End If Case vbKeyF1 If tabOptions.Tab <> 0 Then tabOptions.Tab = tabOptions.Tab - 1 End If Case vbKeyF2 If tabOptions.Tab <> 3 Then tabOptions.Tab = tabOptions.Tab + 1 End If Case vbKeyF8 tabOptions.Tab = 4 DoEvents Case vbKeyF9 tabOptions.Tab = 0 DoEvents Case vbKeyF10 tabOptions.Tab = 1 DoEvents Case vbKeyF11 tabOptions.Tab = 2 DoEvents Case vbKeyF12 tabOptions.Tab = 3 DoEvents End Select Else Select Case KeyCode Case vbKeyF9 tabTest.Tab = 0 DoEvents Case vbKeyF10 tabTest.Tab = 1 DoEvents Case vbKeyF11 tabTest.Tab = 2 DoEvents End Select End If
Anyone know if I'm doing something wrong or whether this is just a bug??
The problem might not be in your switching code, but in the code handled after the change. I didn't see a problem in the code above.
F10 is used by Windows to move focus to a menu. If the current window does not have a menu, then focus is moved to the Windows Control menu. Note - the Form_KeyDown event does not fire if a menu has focus.Quote:
If I hit F10, it acts like it hangs
Try it, hit F10 and then hit the down arrow - a menu should popup. Hitting F10 twice should move focus back to the form.
As Martin pointed out, setting the keycode to 0 will stop Windows from processing the F10 key.
Thank you very much Martin, and Bruce for the explaination. :thumb: