Search code examples
delphipopupmenumemo

1 popup menu and 2 memo's, which memo is the menu invoked from


I have 2 memo's on a form and 1 Tpopupmenu I have assigned the popup menu as the popup menu for both memos. The pop up menu has a couple of menuitem assigned to it, when I right mouse click on either of the memo's and click on one of the menu items on its onclick event I would like to be able to know which memo is the one where the menu was invoked from but cannot figure out how to find out which memo it was!!

Could anyone give me a pointer on how to detect the underlying memo.

thanks

colin


Solution

  • You can use the PopupComponent property of the popup menu:

    procedure TForm1.PopupItemClick(Sender: TObject);
    begin
      if PopupMenu1.PopupComponent = Memo1 then
        ..
      else
        ..