Article ID: 192183
Article Last Modified on 5/13/2003
Private Sub MDIForm_Load()
Form1.Show
Form2.Show
End Sub
Option Explicit
Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
ByVal lParam As Long) As Long
Public Const SC_CLOSE = &HF060
Public Const SC_NEXTWINDOW = &HF040
Public Const WM_SYSCOMMAND = &H112
Public Sub NextWin(KeyCode As Integer, Shift As Integer, sCtl _
As String, hWin As Long)
If (KeyCode = vbKeyTab And (Shift And vbCtrlMask)) Or (KeyCode = _
vbKeyF6 And (Shift And vbCtrlMask)) Then
If Not (sCtl = "CommandButton" Or sCtl = "OptionButton" Or _
sCtl = "TextBox" Or sCtl = "CheckBox" Or _
sCtl = "ListBox") Then ' This line is to save CPU time. _
' Code will work even without this If block
' Modify the If block to include other controls as needed
Call SendMessage(hWin, WM_SYSCOMMAND, SC_NEXTWINDOW, 0)
End If
ElseIf KeyCode = vbKeyF4 And (Shift And vbCtrlMask) Then
Call SendMessage(hWin, WM_SYSCOMMAND, SC_CLOSE, 0)
End If
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
' Any key processing code specific to project.
' Check for CTRL+TAB, CTRL+F6 and
' CTRL+F4 here itself for Forms with intense key processing
NextWin KeyCode, Shift, TypeName(Me.ActiveControl), Me.hwnd
End Sub
189779 BUG: Enabling Accelerator Keys in Visual Basic ActiveX Controls
99688 How to Trap Keystrokes in the Form Instead of Form's Controls
113328 PRB: Form KeyDown Displays Inconsistent Behavior
189616 BUG: DateTimePicker Overrides ALT+F4 Key Combination
149273 BUG: Form Key Events Fire Twice with Some Controls
Additional query words: kbDSupport kbDSD kbVBp kbVBp500 kbVBp600 kbCtrl
Keywords: kbprb KB192183