method PopupMenu.ShowAtWindow (hWnd as Long, Align as MenuAlignEnum, [AlignClientRect as Variant])
Displays the popup menu relative to the given window.

TypeDescription
hWnd as Long A Long expression that specifies the handle of the window that specifies the relative position of the popup menu control. If the hWnd parameter is 0, the popup is aligned relative to the container window.
Align as MenuAlignEnum A MenuAlignEnum expression that specifies the alignment of the popup menu relative to the hWnd window.
AlignClientRect as Variant A String expression that defines the client rectangle to align the popup control relative to the specified window by hWnd parameter. If missing, the popup is aligned to hwnd window's area. If  AlignClientRect parameter is specified, the popup control is aligned to the specified client area relative to hWnd. The string format is as "left,top,width,height", where left indicates the left coordinate, the top indicates the top coordinate, and so on. For instance, "10,10,16,16" indicates a rectangle of 16x16 size that's positioned at 10x10 point relative to the window. If the C: is present in front, the coordinates are relative to window's client area as for instance: "C:10,10,16,16"
ReturnDescription
LongA long expression that specifies the identifier of the item being selected.
Use the ShowAtWindow property to show the popup menu relative to the given window. Use the Show method to show the control at specified coordinates. Use the ShowAtCursor property to show the popup menu at cursor position. If the hWnd parameter is 0, the popup menu is aligned to container window. The AlignClientRect parameter defines the inside client area to be used to align the popup control.

The following VB sample aligns the popup control to the bottom-left corner of the form:

Private Sub Form_Click()
    With Me
        Debug.Print PopupMenu1.ShowAtWindow(.hWnd, MenuBottom)
    End With
End Sub

The following VB sample aligns the popup control to the top-left corner of the form's client area:

Private Sub Form_Click()
    With Me
        Debug.Print PopupMenu1.ShowAtWindow(.hWnd, MenuBottom, "C:0,0")
    End With
End Sub

The following VB sample aligns the popup control to the bottom-right corner of the form:

Private Sub Form_Click()
    With Me
        Debug.Print PopupMenu1.ShowAtWindow(.hWnd, MenuBottom, .Width / Screen.TwipsPerPixelX & "," & .Height / Screen.TwipsPerPixelY)
    End With
End Sub