method PopupMenu.Show (X as OLE_XPOS_PIXELS, Y as OLE_YPOS_PIXELS)

Displays the popup menu at given coordinates, and retrieves the menu command identifier.

 TypeDescription 
   X as OLE_XPOS_PIXELS A long expression that indicates the horizontal position in pixels that  should be relative to the screen.  
   Y as OLE_YPOS_PIXELS A long expression that indicates the vertical position in pixels that  should be relative to the screen.  
 ReturnDescription 
  LongA long expression that indicates the identifier of the selected item. 

Use the Show property to display the control at given coordinates. Use the ShowAtCursor property to display the shortcut menu at cursor. Use the ShowAtWindow property to show the popup menu control relative to specified window. The Command event is never fired during the Show or ShowAtCursor property. 

The following sample shows how to use the Show method:

Private Type POINTAPI
        x As Long
        y As Long
End Type
Private Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
    If (Button = 2) Then
        Dim nID As Long
        Dim p As POINTAPI
        p.x = x / Screen.TwipsPerPixelX
        p.y = y / Screen.TwipsPerPixelY
        ClientToScreen Me.hwnd, p
        nID = PopupMenu1.Show(p.x, p.y)
        If (nID = 1234) Then
            PopupMenu1.Command(1234).Image = (PopupMenu1.Command(1234).Image + 1) Mod 2
        End If
    End If
End Sub


Send comments on this topic.
1999-2016 Exontrol.COM, Software. All rights reserved.