How to determine what control a TPopupMenu was activated for (Views: 100)
How can the event handler of a popup menu item determine which component was right-clicked upon to activate that menu?
Use the PopupMenu.PopupComponent property to determine what control the menu was activated for:
procedure TForm1.PopupItem1Click(Sender: TObject);
Label1.Caption := PopupMenu1.PopupComponent.ClassName;
The form's ActiveControl property can also be used, however, the active control may not necessarily be the control that caused the popup menu to appear.
<< Back to main page