IPopupMenu.Popup

Syntax

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

Parameters

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

X are the coordinates of the popup menu  of X direction.

Y are the coordinates of the popup menu  of Y direction.

Description

The Popup method displays the context menu in the position, the coordinates of which 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 pressing the button calls 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