property PopupMenu.ShowAtCursor as Long

Shows the popup menu at cursor position

TypeDescription
Long A long expression that indicates the identifier of the item selected.

The ShowAtCursor property displays the control at cursor coordinates. Use the Show property if you need to specify the coordinates where the popup menu should be displayed. Use the ShowAtWindow property to show the popup menu control relative to specified window.

The following sample shows how to display the popup at cursor coordinates:

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If (Button = 2) Then
        Dim nID As Long
        nID = PopupMenu1.ShowAtCursor
        If (nID = 1234) Then
            PopupMenu1.Command(1234).Image = (PopupMenu1.Command(1234).Image + 1) Mod 2
         End If
    End If
End Sub