IPopupMenu.Popup

Syntax

Popup(ParentControl: IControl; X: Integer; Y: Integer);

Parameters

ParentControl - parent component, for which the context menu opens. This component will be passed to the argument of the OnPopup event and is available for checking in the IPopupMenuEventArgs.Control property.

X - coordinates of the popup menu along X axis.

Y - coordinates of the popup menu along Y axis.

Description

The Popup method displays the context menu in the position, which coordinates are determined by X and Y parameters.

Comments

The screen coordinates should be specified as the values of X and Y coordinates for this component. Use the IControl.ClientToScreen method to get screen coordinates.

Example

Executing the example requires a form, a button named Button1 on it, the Memo component named Memo1, and the PopupMenu component named PopupMenu1.

    Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
    Var
        p: IPoint;
    Begin
        p := Self.ClientToScreen(Memo1.Left, Memo1.Top);
        PopupMenu1.Popup(Memo1, p.X + 5, p.Y + 5);
    End Sub Button1OnClick;

After executing the example clicking the button opens the context menu in the area of the Memo1 component. The context menu is shifted from the left upper corner for 5 pixels along X and Y axis.

See also:

IPopupMenu