Microsoft KB Archive/192252

= BUG: Menu Accelerators Still Work When Form is Disabled =

Article ID: 192252

Article Last Modified on 5/13/2003

-

APPLIES TO


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

-



This article was previously published under Q192252



SYMPTOMS
You have a Visual Basic form whose Enabled property has been set to False. All user input is disabled except for the menu accelerator keys. The user can still invoke code on a disabled form through the accelerator keys (such as pressing ALT+F X on the keyboard to invoke the File|Exit command).



RESOLUTION
When disabling a Form to prevent all user input, top-level menu items must be disabled as well. For example: Private Sub DisableForm Form1.Enabled = False mnuFile.Enabled = False End Sub



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 in Visual Basic. Form1 is created by default. Add a CommandButton to Form1. Open the Menu Editor (CTRL+E) and add the following menu items:

Caption: &File Name: mnuFile

The next item should be indented:

Caption: E&xit Name: mnuExit

  Add the following code to the Code Window for Form1: Private Sub Form_Load Command1.Caption = "Disable Form" End Sub

Private Sub Command1_Click Me.Enabled = False End Sub

Private Sub mnuExit_Click MsgBox "Exit Called!!" Me.Enabled = True End Sub  Compile the program and run it as an EXE. Click the Disable Form button and then click the Exit menu. As expected, all user input is disabled. This means you cannot select menu items using the mouse. However, you can use the accelerator key combination ALT+X to invoke the menu command. The code in the mnuExit_Click event resets the Enabled property to True.

NOTE: Depending on the version of Windows and Visual Basic you are using, the problem may not appear in the IDE. However, the problem does occur in the compiled executable.</li></ol>

Additional query words: kbDSupport kbDSD kbVBp kbVBp600bug kbVBp500bug kbMenu kbIDE

Keywords: kbbug KB192252

-

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

© Microsoft Corporation. All rights reserved.