unit AutoPopup;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Menus;

type
  TForm1 = class(TForm)
    PopupMenu1: TPopupMenu;
    Hereis1: TMenuItem;
    your1: TMenuItem;
    popup1: TMenuItem;
    menu1: TMenuItem;
    ListBox1: TListBox;
    procedure Hereis1Click(Sender: TObject);
    procedure your1Click(Sender: TObject);
    procedure popup1Click(Sender: TObject);
    procedure menu1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

// BeginExample: AutoPopup
// Property: Menus.TPopupMenu.AutoPopup
// Method: Menus.TPopupMenu.Popup

// BeginCode
{
This example uses a pop-up menu. When the user presses the
mouse button, the pop-up menu appears where the user
clicked the mouse:
} 
procedure TForm1.FormCreate(Sender: TObject);
begin
  PopupMenu1.AutoPopup := False;
end;

procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  PopupMenu1.Popup(Left + X, Top + Y);
end;
// EndCode
// EndExample: AutoPopup

procedure TForm1.Hereis1Click(Sender: TObject);
begin
    ListBox1.Items.Add('"Here is" popup menu');
end;

procedure TForm1.menu1Click(Sender: TObject);
begin
    ListBox1.Items.Add('"menu" popup menu');
end;

procedure TForm1.popup1Click(Sender: TObject);
begin
    ListBox1.Items.Add('"popup" popup menu');
end;

procedure TForm1.your1Click(Sender: TObject);
begin
    ListBox1.Items.Add('"your" popup menu');
end;

end.
