Non-Menu Keys Disabled When Menu Pulled DownLast reviewed: June 21, 1995Article ID: Q99811 |
The information in this article applies to:
- Standard and Professional Editions of Microsoft Visual Basic for Windows, versions 2.0 and 3.0- Microsoft Visual Basic programming system for Windows, version 1.0
SUMMARYWhen a Visual Basic menu is pulled down, all non-menu keystrokes are disabled and keystrokes cannot be detected. This behavior is by design. When a menu is down, all keystrokes just beep or do nothing, except for the keystrokes that control the menu. You cannot determine which menu item the user chose, until after the user clicks the menu item or presses ENTER. The Click event for the menu item will then give you the chosen menu item.
MORE INFORMATION
Access Keys Give a User Keyboard Access to Menu ItemsTo give a user keyboard access to a menu item, insert an ampersand (&) immediately in front of a letter in the Caption by using the Menu Design Window. At run time, this letter (called the access key) is underlined. The user can change the focus to a menu or command by pressing ALT plus the letter (access key).You can use an access key such as ALT+F to give focus quickly to a menu, command, or control by using the keyboard as an alternative to the mouse. Unlike shortcut keys (such as F10 or CTRL+T, which are also assigned in the Menu Design Window), access keys do not execute commands when pressed, until the ENTER key is pressed. If you open a menu with an access key, then all non-menu keystrokes are disabled until you press a menu-control key such as ENTER, ESC, or ALT.
Step-by-Step ExampleTo trap all keystrokes in the form instead of the form's controls, you can set the form's KeyPreview property to True. However, because menu controls disable non-menu key presses when the menu is down, you won't be able to preview or trap keys that are pressed when the menu is down, as this example demonstrates:
|
Additional reference words: 1.00 2.00 3.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |