Microsoft KB Archive/189616

= BUG: DateTimePicker Overrides ALT+F4 Key Combination =

Article ID: 189616

Article Last Modified on 5/13/2003

-

APPLIES TO


 * Microsoft Visual Basic 6.0 Learning Edition
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q189616



SYMPTOMS
When a DateTimePicker (DTPicker) control has focus, the ALT+F4 key combination does not work. If focus is moved to another control such as a TextBox, the ALT+F4 keystroke behaves normally.



RESOLUTION
Utilizing either the KeyDown or KeyUp event of the DTPicker control, you can manually watch for the ALT+F4 keystroke combination and take the appropriate action, such as closing the application.



STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.



Steps to Reproduce Behavior
 Create a new Standard EXE project. Form1 is created by default. Choose Components from the Project menu and add a reference to "Microsoft Windows Common Controls-2". Add a DTPicker control to Form1. Add a TextBox Control to Form1. Run the sample application. Put focus on the DTPicker control if it doesn't have focus already.</li> Press the ALT+F4 keys. Note that the form does not close.</li> Move focus to the TextBox.</li> Press the ALT+F4 keys. The form closes as expected.</li>  To workaround this behavior, paste the following code into Form1's code window: Private Sub DTPicker1_KeyDown(KeyCode As Integer, Shift As Integer) ' Check for Alt and F4 keystrokes If (Shift And vbAltMask) And (KeyCode = vbKeyF4) Then ' Unload the application Unload Me         End If       End Sub </li> Repeat steps 5 - 7 and note that the form closes as expected.</li></ol>

Additional query words: kbDSupport kbDSD kbVBp kbVBp600bug kbCtrl

Keywords: kbbug KB189616

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.