BUG: Incorrect Popup Menu Events Fired with Invisible Menus

Last reviewed: June 21, 1995
Article ID: Q116058
The information in this article applies to:
  • Standard and Professional Editions of Microsoft Visual Basic for Windows, version 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 INFORMATION

Steps to Reproduce Problem

  1. Start a new project in Visual Basic. Form1 is created by default.

  2. Add the following menu items:

        Caption           Name       Visible
        ------------------------------------
        Menu1             mMenu1     False
        ....Menu1Item1    mMenu11    True
        Menu2             mMenu2     False
        ....Menu2Item1    mMenu21    True
    
    

  3. Add the following code for menu items:

       Sub mMenu11_Click ()
          Msgbox "Item1"
       End Sub
    
       Sub mMenu21_Click ()
          MsgBox "Item2"
       End Sub
    
    

  4. 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
    
    

  5. Run the application.

  6. Click the client area of Form1. Then click the Item1 popup menu item. The correct message box will appear.

  7. 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 reference words: buglist3.00 3.00 buglist3.00 hidden
KBCategory: kbprg kbbuglist
KBSubcategory: PrgCtrlsStd


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 21, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.