PRB: Form KeyDown Displays Inconsistent BehaviorLast reviewed: June 21, 1995Article ID: Q113328 |
The information in this article applies to:
- Microsoft Visual Basic programming system for Windows, version 3.0
SYMPTOMSThe KeyDown event on a Form that has KeyPreview set to True may not fire when certain controls have the focus and arrow keys are pressed. Also, the ENTER key won't show up in the KeyPreview if the focus is on a command button.
CAUSEWhen any of the following controls have the Focus, pressing the arrow keys will not cause the Form_KeyDown event to fire:
STATUSThis behavior is by design. The problem is that these controls are subclassed off a default control type provided by Windows. For more information, please see the Visual Basic version 3.0 "Professional Features Book 1" manual, "Control Development Guide," page 87, the paragraph that begins, "If Click were implemented ..." The superclass in Windows treats these keys in a special way, so that the control always gets the keystroke before the form does. When the control itself handles the event, it can reflect the keystroke back to the form for the KeyPreview. But if the superclass handles the event, the control must also avoid handling it in order to prevent conflicts, so there is no way to reflect the keystroke back to the form.
MORE INFORMATION
Steps to Reproduce Behavior
|
Additional reference words: 3.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |