BUG: Incorrect Popup Menu Events Fired with Invisible Menus
ID: Q116058
|
The information in this article applies to:
-
Microsoft Visual Basic Standard and Professional Editions for Windows, versions 2.0, 3.0
SYMPTOMS
When the following conditions are met, Visual Basic may incorrectly fire a
menu's Click event for the first visible menu item under the first menu on
the form:
- You use the PopupMenu method to display a menu that has its Visible
property set to False.
- The PopupMenu is not the first (leftmost) menu on the form, and the
first menu on the form also has its Visible property set to False.
Under these conditions, the Click event for the first visible menu item on
the first menu will be fired immediately after the PopupMenu method is
called, so the desired PopupMenu will not be displayed.
WORKAROUND
To work around this problem, either:
- Make the first menu on the form visible.
-or-
- Place all popup menus on a separate form. Then you can leave all the
menus on your popup menus visible, but make the form that contains
them invisible. To make the form invisible, set the form's visible
property to false. You can invoke popup menus from other forms by
referring to the form name and then the menu name, as in this example:
PopupMenu Form2.Menu2
STATUS
Microsoft has confirmed this to be a bug in Visual Basic version 3.0. We
are researching this problem and will post new information here in the
Microsoft Knowledge Base as it becomes available.
MORE INFORMATIONSteps to Reproduce Problem
- Start a new project in Visual Basic. Form1 is created by default.
- Add the following menu items:
Caption Name Visible
------------------------------------
Menu1 mMenu1 False
....Menu1Item1 mMenu11 True
Menu2 mMenu2 False
....Menu2Item1 mMenu21 True
- Add the following code for menu items:
Sub mMenu11_Click ()
Msgbox "Item1"
End Sub
Sub mMenu21_Click ()
MsgBox "Item2"
End Sub
- Add the following code to the Form_MouseDown event:
' Place following two lines of code on one, single line:
Sub Form_MouseDown (button As Integer, Shift As Integer, X As Single,
Y As Single)
If button = 2 Then
PopupMenu mMenu2
Else
PopupMenu mMenu1
End If
End Sub
- Run the application.
- Click the client area of Form1. Then click the Item1 popup menu item.
The correct message box will appear.
- With Right mouse button, click the client area of Form1. The Item1
message box will appear, indicating the click event was generated
for the first menu item under top-level menu 1.
Additional query words:
buglist3.00 3.00 buglist3.00 hidden
Keywords :
Version :
Platform :
Issue type :
|