//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "OnPopup.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
// BeginExample: OnPopup
// Event: Menus.TPopupMenu.OnPopup

// BeginCode
/*
The following code enables the Copy item from the pop-up
menu if the edit control has a nonempty selection.
Note: A portion of the edit control text must be highlighted.
*/
void __fastcall TForm1::PopupMenu1Popup(TObject *Sender)
{
  Copy1->Enabled = (Edit1->SelLength > 0);
}

void __fastcall TForm1::Copy1Click(TObject *Sender)
{
	ListBox1->Items->Add("'Copy' menu");
}

void __fastcall TForm1::FormMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift,
          int X, int Y)
{
  PopupMenu1->Popup(X, Y);
}
// EndCode
// EndExample: OnPopup

void __fastcall TForm1::Hereis1Click(TObject *Sender)
{
  ListBox1->Items->Add("'Here is' popup menu");
}

void __fastcall TForm1::menu1Click(TObject *Sender)
{
  ListBox1->Items->Add("'menu' popup menu");
}

void __fastcall TForm1::popup1Click(TObject *Sender)
{
  ListBox1->Items->Add("'popup' popup menu");
}

void __fastcall TForm1::your1Click(TObject *Sender)
{
  ListBox1->Items->Add("'your' popup menu");
}
//---------------------------------------------------------------------------

