BUG: Form Key Events Fire Twice with SSTab Control
ID: Q149273
|
The information in this article applies to:
-
Microsoft Visual Basic Learning, Professional, and Enterprise Editions for Windows, versions 5.0, 6.0
-
Microsoft Visual Basic Standard, Professional, and Enterprise Editions, 16-bit and 32-bit, for Windows, version 4.0
SYMPTOMS
If an SSTab, SSFrame or SSPanel control has the focus and a key is pressed,
then all of the Form level key events (Form_KeyDown, Form_KeyPress, and
Form_KeyUp) will be fired twice. This problem occurs only if the KeyPreview
property of the form is set to True.
RESOLUTION
It may be possible to write code to ignore the second key event if focus is
on the tab control. This could be done by utilizing a global flag variable
to represent whether or not the key event had been raised before. Aside
from this, the best option is to avoid writing code that depends on this
functionality.
STATUS
Microsoft has confirmed this to be an issue in the Microsoft products
listed at the beginning of this article.
MORE INFORMATIONSteps to Reproduce Behavior
- Start a new Standard EXE Project in Visual Basic, Form1 is created by
default.
- Draw a single SSTab control onto Form1.
- Change this property of Form1:
KeyPreview: True
- Add this code to the form:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Debug.Print "Form KeyDown"
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
Debug.Print "Form_KeyPress"
End Sub
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
Debug.Print "Form KeyUp"
End Sub
Private Sub SSTab1_KeyDown(KeyCode As Integer, Shift As Integer)
Debug.Print "SSTab KeyDown"
End Sub
Private Sub SSTab1_KeyPress(KeyAscii As Integer)
Debug.Print "SSTab KeyPress"
End Sub
Private Sub SSTab1_KeyUp(KeyCode As Integer, Shift As Integer)
Debug.Print "SSTab KeyUp"
End Sub
- Press F5 or select Start from the Run menu to run the application. Click
once on the SSTab to ensure that it has the focus. Then press a single
key on the keyboard. Observe the output in the debug window to see that
each form key event has been fired twice.
Additional query words:
kbVBp400bug kbVBp500bug kbCtrl kbVBp kbdsd kbDSupport
Keywords : kbVBp400bug kbVBp500bug kbGrpVB
Version :
Platform : NT WINDOWS
Issue type : kbbug
|