OnPopup (C++)

From RAD Studio Code Examples
Jump to: navigation, search


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);