Defining the parent component

We have TToolbarButton (s) in the toolbar, each with its own TPopupMenu. The popup menus are all the same, so we would like to have only one menu for all the toolbar buttons. The problem I'm running into is determining that the ToolbarButton is causing the popup menu.

I have tried the following, but I keep breaking access.

...

with (Sender as TPopupMenu) do
  ShowMessage((GetParentComponent as TPopupMenu).Name);

      

...

Any ideas on how to get the parent of the popup menu?

Thanks, Peter.

0


a source to share


1 answer


Try

  with (sender as  TPopupMenu)  do
      ShowMessage(PopupComponent.Name);

      



This should give you the TToolButton that was clicked.

+6


a source







All Articles