PopupMenu Method
      Displays a pop-up menu on an MDIForm or Form object at the current mouse location or at specified coordinates. Doesn't support named arguments.Syntaxobject.PopupMenu menuname, flags, x, y, boldcommandThe PopupMenu method syntax has these parts:Part Description 
object Optional. An object expression that evaluates to an object in the Applies To list. If object is omitted, the form with the focus is assumed to be object. 
Menuname Required. The name of the pop-up menu to be displayed. The specified menu must have at least one submenu. 
Flags Optional. A value or constant that specifies the location and behavior of a pop-up menu, as described in Settings. 
X Optional. Specifies the x-coordinate where the pop-up menu is displayed. If omitted, the mouse coordinate is used. 
Y Optional. Specifies the y-coordinate where the pop-up menu is displayed. If omitted, the mouse coordinate is used. 
boldcommand Optional. Specifies the name of a menu control in the pop-up menu to display its caption in bold text. If omitted, no controls in the pop-up menu appear in bold. 
SettingsThe settings for flags are:Constant (location) Value Description 
vbPopupMenuLeftAlign 0 (Default) The left side of the pop-up menu is located at x. 
vbPopupMenuCenterAlign 4 The pop-up menu is centered at x. 
vbPopupMenuRightAlign 8 The right side of the pop-up menu is located at x. Constant (behavior) Value Description 
vbPopupMenuLeftButton 0 (Default) An item on the pop-up menu reacts to a mouse click only when you use the left mouse button. 
vbPopupMenuRightButton 2 An item on the pop-up menu reacts to a mouse click when you use either the right or the left mouse button. 
ResThese constants are listed in the Visual Basic (VB) object library in the Object Browser.You specify the unit of measure for the x and y coordinates using the ScaleMode property. The x and y coordinates define where the pop-up is displayed relative to the specified form. If the x and y coordinates aren't included, the pop-up menu is displayed at the current location of the mouse pointer.When you display a pop-up menu, the code following the call to the PopupMenu method isn't executed until the user either chooses a command from the menu (in which case the code for that command's Click event is executed before the code following the PopupMenu statement) or cancels the menu. In addition, only one pop-up menu can be displayed at a time; therefore, calls to this method are ignored if a pop-up menu is already displayed or if a pull-down menu is open.

解决方案 »

  1.   


    Private Sub picture1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
        If Button = 2 Then
            PopupMenu a
        End If
    End Sub
      

  2.   

    ok,谢谢大家:)
    还有一个问题,使用PopupMenu方法后怎样定制菜单选项呢?
      

  3.   

    Private Sub picture1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
        If Button = 2 Then
            PopupMenu a
        End If
    End Suba 是定义的一组菜单,属性Visible=False
      

  4.   

    用菜单编辑器生成一个菜单,caption不写,visible设为不可见,你准备显示的菜单项作为这个菜单的子菜单。然后把下面代码写到你的控件的MouseUp事件里:
    If Button = 2 Then PopupMenu 菜单名