获取TPopupMenu的调用组件

Get the calling component of TPopupMenu

我有一个 TStringGrid,它连接了一个 TPopupMenu。 通过单击弹出菜单的一个事件,我想获取调用组件。这可能吗?

背景: 这是一个更大的项目,每个表单都有一个我可以继承的“BasicForm”。所以我想为其中包含 Copy、Select 等内容的网格提供一个“默认弹出菜单”。在继承的形式中,我只将网格(如果存在)与该弹出窗口匹配,我就完成了。

您似乎在寻找 TPopupMenu 的 PopupComponent 属性: Vcl.Menus.TPopupMenu.PopupComponent

Indicates the component that last displayed the popup menu in response to a right mouse click.

Read PopupComponent to determine which control is currently using the popup menu. In applications where multiple controls share the same pop-up menu, use PopupComponent to determine which of them displayed the menu.

Set PopupComponent to associate a control with the menu before calling the Popup method programmatically to bring up the pop-up menu.